├── x264c ├── external │ ├── x264 │ │ ├── VERSION │ │ ├── vendor.go │ │ ├── common │ │ │ ├── arm │ │ │ │ ├── vendor.go │ │ │ │ ├── mc.h │ │ │ │ ├── bitstream.h │ │ │ │ ├── bitstream-a.S │ │ │ │ ├── quant.h │ │ │ │ ├── dct.h │ │ │ │ ├── deblock.h │ │ │ │ ├── cpu-a.S │ │ │ │ └── predict-c.c │ │ │ ├── ppc │ │ │ │ ├── vendor.go │ │ │ │ ├── mc.h │ │ │ │ ├── pixel.h │ │ │ │ ├── predict.h │ │ │ │ ├── deblock.h │ │ │ │ ├── quant.h │ │ │ │ └── dct.h │ │ │ ├── vendor.go │ │ │ ├── x86 │ │ │ │ ├── vendor.go │ │ │ │ ├── mc.h │ │ │ │ ├── const-a.asm │ │ │ │ ├── cpu-a.asm │ │ │ │ ├── bitstream-a.asm │ │ │ │ └── bitstream.h │ │ │ ├── aarch64 │ │ │ │ ├── vendor.go │ │ │ │ ├── mc.h │ │ │ │ ├── bitstream.h │ │ │ │ ├── asm-offsets.h │ │ │ │ ├── asm-offsets.c │ │ │ │ ├── bitstream-a.S │ │ │ │ ├── deblock.h │ │ │ │ ├── quant.h │ │ │ │ ├── predict-c.c │ │ │ │ ├── cabac-a.S │ │ │ │ └── dct.h │ │ │ ├── mips │ │ │ │ ├── vendor.go │ │ │ │ ├── mc.h │ │ │ │ ├── quant.h │ │ │ │ ├── deblock.h │ │ │ │ ├── dct.h │ │ │ │ └── predict.h │ │ │ ├── opencl │ │ │ │ ├── vendor.go │ │ │ │ ├── weightp.cl │ │ │ │ ├── x264-cl.h │ │ │ │ └── downscale.cl │ │ │ ├── common.c │ │ │ ├── threadpool.h │ │ │ ├── rectangle.c │ │ │ ├── cpu.h │ │ │ ├── win32thread.h │ │ │ ├── dct.h │ │ │ ├── osdep.c │ │ │ ├── quant.h │ │ │ ├── vlc.c │ │ │ ├── tables.h │ │ │ ├── set.h │ │ │ └── cabac.h │ │ ├── encoder │ │ │ ├── vendor.go │ │ │ ├── slicetype-cl.h │ │ │ ├── analyse.h │ │ │ ├── set.h │ │ │ ├── me.h │ │ │ └── ratecontrol.h │ │ └── AUTHORS │ └── vendor.go ├── go.mod ├── common_cpu.go ├── common_dct.go ├── common_mc.go ├── common_set.go ├── common_vlc.go ├── encoder_me.go ├── common_base.go ├── common_cabac.go ├── common_frame.go ├── common_osdep.go ├── common_pixel.go ├── common_quant.go ├── encoder_api.go ├── encoder_set.go ├── common_common.go ├── common_deblock.go ├── common_mvpred.go ├── common_predict.go ├── common_tables.go ├── encoder_analyse.go ├── encoder_cabac.go ├── encoder_cavlc.go ├── encoder_encoder.go ├── common_bitstream.go ├── common_macroblock.go ├── common_rectangle.go ├── common_threadpool.go ├── encoder_lookahead.go ├── encoder_macroblock.go ├── encoder_ratecontrol.go ├── x264c_cgo_extlib_pkgconfig.go ├── common_win32thread_windows.go ├── x264c_cgo_extlib.go ├── x264c_param_test.go └── x264c_cgo.go ├── yuv ├── go.mod ├── README ├── options.go ├── yuv.h └── yuv.go ├── AUTHORS ├── examples ├── basic │ ├── example.jpg │ ├── go.mod │ ├── go.sum │ └── basic.go └── screengrab │ ├── go.mod │ ├── screengrab.go │ └── go.sum ├── go.mod ├── ycbcr_test.go ├── go.sum ├── vendor.go ├── .github └── workflows │ └── build.yml ├── ycbcr.go ├── README.md └── encode_test.go /x264c/external/x264/VERSION: -------------------------------------------------------------------------------- 1 | 0.164.x 2 | -------------------------------------------------------------------------------- /x264c/external/vendor.go: -------------------------------------------------------------------------------- 1 | //go:build required 2 | 3 | package vendor 4 | -------------------------------------------------------------------------------- /yuv/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/gen2brain/x264-go/yuv 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /x264c/external/x264/vendor.go: -------------------------------------------------------------------------------- 1 | //go:build required 2 | 3 | package vendor 4 | -------------------------------------------------------------------------------- /x264c/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/gen2brain/x264-go/x264c 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /x264c/external/x264/common/arm/vendor.go: -------------------------------------------------------------------------------- 1 | //go:build required 2 | 3 | package vendor 4 | -------------------------------------------------------------------------------- /x264c/external/x264/common/ppc/vendor.go: -------------------------------------------------------------------------------- 1 | //go:build required 2 | 3 | package vendor 4 | -------------------------------------------------------------------------------- /x264c/external/x264/common/vendor.go: -------------------------------------------------------------------------------- 1 | //go:build required 2 | 3 | package vendor 4 | -------------------------------------------------------------------------------- /x264c/external/x264/common/x86/vendor.go: -------------------------------------------------------------------------------- 1 | //go:build required 2 | 3 | package vendor 4 | -------------------------------------------------------------------------------- /x264c/external/x264/encoder/vendor.go: -------------------------------------------------------------------------------- 1 | //go:build required 2 | 3 | package vendor 4 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Milan Nikolic 2 | Faris Khowarizmi 3 | -------------------------------------------------------------------------------- /x264c/external/x264/common/aarch64/vendor.go: -------------------------------------------------------------------------------- 1 | //go:build required 2 | 3 | package vendor 4 | -------------------------------------------------------------------------------- /x264c/external/x264/common/mips/vendor.go: -------------------------------------------------------------------------------- 1 | //go:build required 2 | 3 | package vendor 4 | -------------------------------------------------------------------------------- /x264c/external/x264/common/opencl/vendor.go: -------------------------------------------------------------------------------- 1 | //go:build required 2 | 3 | package vendor 4 | -------------------------------------------------------------------------------- /yuv/README: -------------------------------------------------------------------------------- 1 | Imported from https://github.com/giongto35/cloud-game/tree/master/pkg/encoder/yuv 2 | -------------------------------------------------------------------------------- /examples/basic/example.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gen2brain/x264-go/HEAD/examples/basic/example.jpg -------------------------------------------------------------------------------- /x264c/common_cpu.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/common/cpu.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/common_dct.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/common/dct.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/common_mc.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/common/mc.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/common_set.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/common/set.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/common_vlc.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/common/vlc.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/encoder_me.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/encoder/me.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/common_base.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/common/base.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/common_cabac.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/common/cabac.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/common_frame.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/common/frame.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/common_osdep.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/common/osdep.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/common_pixel.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/common/pixel.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/common_quant.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/common/quant.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/encoder_api.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/encoder/api.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/encoder_set.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/encoder/set.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/common_common.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/common/common.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/common_deblock.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/common/deblock.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/common_mvpred.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/common/mvpred.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/common_predict.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/common/predict.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/common_tables.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/common/tables.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/encoder_analyse.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/encoder/analyse.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/encoder_cabac.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/encoder/cabac.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/encoder_cavlc.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/encoder/cavlc.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/encoder_encoder.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/encoder/encoder.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/common_bitstream.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/common/bitstream.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/common_macroblock.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/common/macroblock.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/common_rectangle.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/common/rectangle.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/common_threadpool.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/common/threadpool.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/encoder_lookahead.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/encoder/lookahead.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/encoder_macroblock.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/encoder/macroblock.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/encoder_ratecontrol.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/encoder/ratecontrol.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/x264c_cgo_extlib_pkgconfig.go: -------------------------------------------------------------------------------- 1 | //go:build extlib && pkgconfig 2 | // +build extlib,pkgconfig 3 | 4 | package x264c 5 | 6 | /* 7 | #cgo pkg-config: x264 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /x264c/common_win32thread_windows.go: -------------------------------------------------------------------------------- 1 | //go:build windows && !extlib 2 | // +build windows,!extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #include "external/x264/common/win32thread.c" 8 | */ 9 | import "C" 10 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/gen2brain/x264-go 2 | 3 | go 1.23 4 | 5 | require ( 6 | github.com/gen2brain/x264-go/x264c v0.0.0-20221204084822-82ee2951dea2 7 | github.com/gen2brain/x264-go/yuv v0.0.0-20221204084822-82ee2951dea2 8 | ) 9 | -------------------------------------------------------------------------------- /examples/basic/go.mod: -------------------------------------------------------------------------------- 1 | module basic 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/gen2brain/x264-go v0.2.1 7 | github.com/gen2brain/x264-go/x264c v0.0.0-20220828142632-56f773492998 // indirect 8 | github.com/gen2brain/x264-go/yuv v0.0.0-20220828142632-56f773492998 // indirect 9 | ) 10 | -------------------------------------------------------------------------------- /x264c/x264c_cgo_extlib.go: -------------------------------------------------------------------------------- 1 | //go:build extlib && !pkgconfig 2 | // +build extlib,!pkgconfig 3 | 4 | package x264c 5 | 6 | /* 7 | #cgo android LDFLAGS: -lx264 -lm 8 | #cgo windows LDFLAGS: -lx264 9 | #cgo linux LDFLAGS: -lx264 -lm 10 | #cgo darwin LDFLAGS: -lx264 -lm 11 | */ 12 | import "C" 13 | -------------------------------------------------------------------------------- /x264c/x264c_param_test.go: -------------------------------------------------------------------------------- 1 | package x264c 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | "unsafe" 7 | ) 8 | 9 | func TestRawParamSize(t *testing.T) { 10 | if rawParamSize == unsafe.Sizeof(Param{}) { 11 | return 12 | } 13 | 14 | t.Fatal(fmt.Sprintf("%v != %v", rawParamSize, unsafe.Sizeof(Param{}))) 15 | } 16 | -------------------------------------------------------------------------------- /ycbcr_test.go: -------------------------------------------------------------------------------- 1 | package x264 2 | 3 | import ( 4 | "image" 5 | "testing" 6 | ) 7 | 8 | func TestYCbCr(t *testing.T) { 9 | var img image.Image 10 | 11 | rgba := image.NewRGBA(image.Rect(0, 0, 640, 480)) 12 | 13 | ycbcr := NewYCbCr(rgba.Bounds()) 14 | ycbcr.ToYCbCr(rgba) 15 | 16 | img = ycbcr 17 | 18 | _, ok := img.(*YCbCr) 19 | if !ok { 20 | t.Error("ToYCbCr failed") 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/gen2brain/x264-go/x264c v0.0.0-20221204084822-82ee2951dea2 h1:4GzTsZK/uG+tHvWR2ORcTCGTC4+mgOPhkUdz/Ro9alg= 2 | github.com/gen2brain/x264-go/x264c v0.0.0-20221204084822-82ee2951dea2/go.mod h1:MUMv+ZURlTO3qH8QAt2gxiIY5X4NMaxObz2ImZOMvyA= 3 | github.com/gen2brain/x264-go/yuv v0.0.0-20221204084822-82ee2951dea2 h1:lihaRUKRj94EWVZRp1jTmEiIxmvjEiSb9fJl2xftrXY= 4 | github.com/gen2brain/x264-go/yuv v0.0.0-20221204084822-82ee2951dea2/go.mod h1:PzzJntdOaVt4Gc37fNaEXpqmhKkUgd/xqyPMUfx+FQc= 5 | -------------------------------------------------------------------------------- /examples/screengrab/go.mod: -------------------------------------------------------------------------------- 1 | module screengrab 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/gen2brain/shm v0.0.0-20221026125803-c33c9e32b1c8 // indirect 7 | github.com/gen2brain/x264-go v0.2.3 8 | github.com/gen2brain/x264-go/x264c v0.0.0-20221224044516-9a74c944fe06 // indirect 9 | github.com/gen2brain/x264-go/yuv v0.0.0-20221224044516-9a74c944fe06 // indirect 10 | github.com/jezek/xgb v1.1.0 // indirect 11 | github.com/kbinani/screenshot v0.0.0-20210720154843-7d3a670d8329 12 | golang.org/x/sys v0.6.0 // indirect 13 | ) 14 | -------------------------------------------------------------------------------- /vendor.go: -------------------------------------------------------------------------------- 1 | //go:build required 2 | 3 | package x264 4 | 5 | import ( 6 | _ "github.com/gen2brain/x264-go/x264c/external" 7 | _ "github.com/gen2brain/x264-go/x264c/external/x264" 8 | _ "github.com/gen2brain/x264-go/x264c/external/x264/common" 9 | _ "github.com/gen2brain/x264-go/x264c/external/x264/common/aarch64" 10 | _ "github.com/gen2brain/x264-go/x264c/external/x264/common/arm" 11 | _ "github.com/gen2brain/x264-go/x264c/external/x264/common/mips" 12 | _ "github.com/gen2brain/x264-go/x264c/external/x264/common/opencl" 13 | _ "github.com/gen2brain/x264-go/x264c/external/x264/common/ppc" 14 | _ "github.com/gen2brain/x264-go/x264c/external/x264/common/x86" 15 | _ "github.com/gen2brain/x264-go/x264c/external/x264/encoder" 16 | ) 17 | -------------------------------------------------------------------------------- /yuv/options.go: -------------------------------------------------------------------------------- 1 | package yuv 2 | 3 | type Options struct { 4 | ChromaP ChromaPos 5 | Threaded bool 6 | Threads int 7 | } 8 | 9 | func (o *Options) override(options ...Option) { 10 | for _, opt := range options { 11 | opt(o) 12 | } 13 | } 14 | 15 | type Option func(*Options) 16 | 17 | func Threaded(t bool) Option { 18 | return func(opts *Options) { 19 | opts.Threaded = t 20 | } 21 | } 22 | 23 | func Threads(t int) Option { 24 | return func(opts *Options) { 25 | opts.Threads = t 26 | } 27 | } 28 | 29 | func ChromaP(cp ChromaPos) Option { 30 | return func(opts *Options) { 31 | opts.ChromaP = cp 32 | } 33 | } 34 | 35 | // WithOptions used for config files. 36 | func WithOptions(arg Options) Option { 37 | return func(args *Options) { 38 | args.ChromaP = arg.ChromaP 39 | args.Threaded = arg.Threaded 40 | args.Threads = arg.Threads 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /examples/basic/go.sum: -------------------------------------------------------------------------------- 1 | github.com/gen2brain/x264-go v0.2.1 h1:5KV+GZk/YH8oUVvFijfJ3JoSIxexkSv/5ALp4v6NUq8= 2 | github.com/gen2brain/x264-go v0.2.1/go.mod h1:F6mwU9FyzrUbWE0f9lWdTPHBEDt/ugle+H61peryCZQ= 3 | github.com/gen2brain/x264-go/x264c v0.0.0-20220828141959-ddbf4cbb9814/go.mod h1:lshP4xmJNPCHscewcvsemVs62q8J8F0mh+FYBAfVG60= 4 | github.com/gen2brain/x264-go/x264c v0.0.0-20220828142632-56f773492998 h1:GPcrJdpf6lUg5FCfriDnyYvRbwVwdOnBbaBHv0UgRQ4= 5 | github.com/gen2brain/x264-go/x264c v0.0.0-20220828142632-56f773492998/go.mod h1:lshP4xmJNPCHscewcvsemVs62q8J8F0mh+FYBAfVG60= 6 | github.com/gen2brain/x264-go/yuv v0.0.0-20220622130850-9f6285ee8073/go.mod h1:xGOE/2fXjxu/ZONrm0EPqKHj/XDc13al1o48I3FQfHA= 7 | github.com/gen2brain/x264-go/yuv v0.0.0-20220828142632-56f773492998 h1:gKMkjbAy0Jnuacd0d296f918g/fIlBSDmNijNvZ4CdY= 8 | github.com/gen2brain/x264-go/yuv v0.0.0-20220828142632-56f773492998/go.mod h1:xGOE/2fXjxu/ZONrm0EPqKHj/XDc13al1o48I3FQfHA= 9 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | on: [push, pull_request] 2 | name: Build 3 | jobs: 4 | test: 5 | strategy: 6 | matrix: 7 | go-version: [1.23.x] 8 | os: [ubuntu-latest, macos-latest, windows-latest] 9 | runs-on: ${{ matrix.os }} 10 | steps: 11 | - name: Checkout code 12 | uses: actions/checkout@v4 13 | - name: Install Go 14 | uses: actions/setup-go@v5 15 | with: 16 | go-version: ${{ matrix.go-version }} 17 | - name: Build 18 | run: go build 19 | 20 | test-extlib: 21 | runs-on: ubuntu-latest 22 | steps: 23 | - name: Checkout code 24 | uses: actions/checkout@v4 25 | - name: Install Go 26 | uses: actions/setup-go@v5 27 | with: 28 | go-version: ${{ matrix.go-version }} 29 | - name: Install packages 30 | run: | 31 | sudo apt-get update -y; sudo apt-get -y install libx264-dev 32 | - name: Build 33 | run: go build -tags extlib 34 | -------------------------------------------------------------------------------- /yuv/yuv.h: -------------------------------------------------------------------------------- 1 | typedef enum { 2 | // It will take each TL pixel for chroma values. 3 | // XO X XO X 4 | // X X X X 5 | TOP_LEFT = 0, 6 | // It will take an average color from the 2x2 pixel group for chroma values. 7 | // X X X X 8 | // O O 9 | // X X X X 10 | BETWEEN_FOUR = 1 11 | } chromaPos; 12 | 13 | // Converts RGBA image to YUV (I420) with BT.601 studio color range. 14 | void rgbaToYuv(void *destination, void *source, int width, int height, chromaPos chroma); 15 | 16 | // Converts RGBA image chunk to YUV (I420) chroma with BT.601 studio color range. 17 | // pos contains a shift value for chunks. 18 | // deu, dev contains constant shifts for U, V planes in the resulting array. 19 | // chroma (0, 1) selects chroma estimation algorithm. 20 | void chroma(void *destination, void *source, int pos, int deu, int dev, int width, int height, chromaPos chroma); 21 | 22 | // Converts RGBA image chunk to YUV (I420) luma with BT.601 studio color range. 23 | void luma(void *destination, void *source, int pos, int width, int height); 24 | -------------------------------------------------------------------------------- /examples/basic/basic.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "image" 6 | _ "image/jpeg" 7 | "os" 8 | 9 | "github.com/gen2brain/x264-go" 10 | ) 11 | 12 | func main() { 13 | opts := &x264.Options{ 14 | Width: 640, 15 | Height: 480, 16 | FrameRate: 25, 17 | Preset: "veryfast", 18 | Tune: "stillimage", 19 | Profile: "baseline", 20 | LogLevel: x264.LogDebug, 21 | } 22 | 23 | w, err := os.Create("example.264") 24 | if err != nil { 25 | fmt.Println(err) 26 | os.Exit(1) 27 | } 28 | 29 | defer w.Close() 30 | 31 | enc, err := x264.NewEncoder(w, opts) 32 | if err != nil { 33 | fmt.Println(err) 34 | os.Exit(1) 35 | } 36 | 37 | defer enc.Close() 38 | 39 | r, err := os.Open("example.jpg") 40 | if err != nil { 41 | fmt.Println(err) 42 | os.Exit(1) 43 | } 44 | 45 | img, _, err := image.Decode(r) 46 | if err != nil { 47 | fmt.Println(err) 48 | os.Exit(1) 49 | } 50 | 51 | err = enc.Encode(img) 52 | if err != nil { 53 | fmt.Println(err) 54 | os.Exit(1) 55 | } 56 | 57 | err = enc.Flush() 58 | if err != nil { 59 | fmt.Println(err) 60 | os.Exit(1) 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /x264c/external/x264/common/ppc/mc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * mc.h: ppc motion compensation 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2022 x264 project 5 | * 6 | * Authors: Eric Petit 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_PPC_MC_H 27 | #define X264_PPC_MC_H 28 | 29 | #define x264_mc_init_altivec x264_template(mc_init_altivec) 30 | void x264_mc_init_altivec( x264_mc_functions_t *pf ); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /x264c/external/x264/common/arm/mc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * mc.h: arm motion compensation 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2022 x264 project 5 | * 6 | * Authors: David Conrad 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_ARM_MC_H 27 | #define X264_ARM_MC_H 28 | 29 | #define x264_mc_init_arm x264_template(mc_init_arm) 30 | void x264_mc_init_arm( uint32_t cpu, x264_mc_functions_t *pf ); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /x264c/external/x264/common/mips/mc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * mc.h: msa motion compensation 3 | ***************************************************************************** 4 | * Copyright (C) 2015-2022 x264 project 5 | * 6 | * Authors: Neha Rana 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_MIPS_MC_H 27 | #define X264_MIPS_MC_H 28 | 29 | #define x264_mc_init_mips x264_template(mc_init_mips) 30 | void x264_mc_init_mips( uint32_t cpu, x264_mc_functions_t *pf ); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /x264c/external/x264/common/ppc/pixel.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * pixel.h: ppc pixel metrics 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2022 x264 project 5 | * 6 | * Authors: Eric Petit 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_PPC_PIXEL_H 27 | #define X264_PPC_PIXEL_H 28 | 29 | #define x264_pixel_init_altivec x264_template(pixel_init_altivec) 30 | void x264_pixel_init_altivec( x264_pixel_function_t *pixf ); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /x264c/external/x264/common/aarch64/mc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * mc.h: aarch64 motion compensation 3 | ***************************************************************************** 4 | * Copyright (C) 2014-2022 x264 project 5 | * 6 | * Authors: Janne Grunau 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_AARCH64_MC_H 27 | #define X264_AARCH64_MC_H 28 | 29 | #define x264_mc_init_aarch64 x264_template(mc_init_aarch64) 30 | void x264_mc_init_aarch64( uint32_t cpu, x264_mc_functions_t *pf ); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /x264c/external/x264/common/arm/bitstream.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * bitstream.h: arm bitstream functions 3 | ***************************************************************************** 4 | * Copyright (C) 2017-2022 x264 project 5 | * 6 | * Authors: Anton Mitrofanov 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_ARM_BITSTREAM_H 27 | #define X264_ARM_BITSTREAM_H 28 | 29 | #define x264_nal_escape_neon x264_template(nal_escape_neon) 30 | uint8_t *x264_nal_escape_neon( uint8_t *dst, uint8_t *src, uint8_t *end ); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /x264c/external/x264/common/x86/mc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * mc.h: x86 motion compensation 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2022 x264 project 5 | * 6 | * Authors: Loren Merritt 7 | * Laurent Aimar 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 22 | * 23 | * This program is also available under a commercial proprietary license. 24 | * For more information, contact us at licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #ifndef X264_X86_MC_H 28 | #define X264_X86_MC_H 29 | 30 | #define x264_mc_init_mmx x264_template(mc_init_mmx) 31 | void x264_mc_init_mmx( uint32_t cpu, x264_mc_functions_t *pf ); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /x264c/external/x264/common/aarch64/bitstream.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * bitstream.h: aarch64 bitstream functions 3 | ***************************************************************************** 4 | * Copyright (C) 2017-2022 x264 project 5 | * 6 | * Authors: Anton Mitrofanov 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_AARCH64_BITSTREAM_H 27 | #define X264_AARCH64_BITSTREAM_H 28 | 29 | #define x264_nal_escape_neon x264_template(nal_escape_neon) 30 | uint8_t *x264_nal_escape_neon( uint8_t *dst, uint8_t *src, uint8_t *end ); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /x264c/external/x264/common/ppc/predict.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * predict.h: ppc intra prediction 3 | ***************************************************************************** 4 | * Copyright (C) 2007-2022 x264 project 5 | * 6 | * Authors: Guillaume Poirier 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_PPC_PREDICT_H 27 | #define X264_PPC_PREDICT_H 28 | 29 | #define x264_predict_16x16_init_altivec x264_template(predict_16x16_init_altivec) 30 | void x264_predict_16x16_init_altivec( x264_predict_t pf[7] ); 31 | #define x264_predict_8x8c_init_altivec x264_template(predict_8x8c_init_altivec) 32 | void x264_predict_8x8c_init_altivec( x264_predict_t pf[7] ); 33 | 34 | #endif /* X264_PPC_PREDICT_H */ 35 | -------------------------------------------------------------------------------- /examples/screengrab/screengrab.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "os" 7 | "os/signal" 8 | "syscall" 9 | "time" 10 | 11 | "github.com/gen2brain/x264-go" 12 | "github.com/kbinani/screenshot" 13 | ) 14 | 15 | func main() { 16 | file, err := os.Create("screen.264") 17 | if err != nil { 18 | fmt.Fprintf(os.Stderr, "%s\n", err.Error()) 19 | os.Exit(1) 20 | } 21 | 22 | bounds := screenshot.GetDisplayBounds(0) 23 | 24 | opts := &x264.Options{ 25 | Width: bounds.Dx(), 26 | Height: bounds.Dy(), 27 | FrameRate: 25, 28 | Tune: "zerolatency", 29 | Preset: "ultrafast", 30 | Profile: "baseline", 31 | LogLevel: x264.LogError, 32 | } 33 | 34 | enc, err := x264.NewEncoder(file, opts) 35 | if err != nil { 36 | fmt.Fprintf(os.Stderr, "%s\n", err.Error()) 37 | os.Exit(1) 38 | } 39 | 40 | defer enc.Close() 41 | 42 | s := make(chan os.Signal, 1) 43 | signal.Notify(s, os.Interrupt, syscall.SIGTERM) 44 | 45 | ticker := time.NewTicker(time.Second / time.Duration(25)) 46 | 47 | start := time.Now() 48 | frame := 0 49 | 50 | for range ticker.C { 51 | select { 52 | case <-s: 53 | enc.Flush() 54 | 55 | err = file.Close() 56 | if err != nil { 57 | fmt.Fprintf(os.Stderr, "%s\n", err.Error()) 58 | os.Exit(1) 59 | } 60 | 61 | os.Exit(0) 62 | default: 63 | frame++ 64 | log.Printf("frame: %v", frame) 65 | img, err := screenshot.CaptureRect(bounds) 66 | if err != nil { 67 | fmt.Fprintf(os.Stderr, "%s\n", err.Error()) 68 | continue 69 | } 70 | 71 | err = enc.Encode(img) 72 | if err != nil { 73 | fmt.Fprintf(os.Stderr, "%s\n", err.Error()) 74 | } 75 | log.Printf("t: %v", time.Since(start)) 76 | start = time.Now() 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /x264c/external/x264/common/ppc/deblock.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * deblock.h: ppc deblocking 3 | ***************************************************************************** 4 | * Copyright (C) 2017-2022 x264 project 5 | * 6 | * Authors: Anton Mitrofanov 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_PPC_DEBLOCK_H 27 | #define X264_PPC_DEBLOCK_H 28 | 29 | #define x264_deblock_v_luma_altivec x264_template(deblock_v_luma_altivec) 30 | void x264_deblock_v_luma_altivec( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 31 | #define x264_deblock_h_luma_altivec x264_template(deblock_h_luma_altivec) 32 | void x264_deblock_h_luma_altivec( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /x264c/external/x264/common/aarch64/asm-offsets.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * asm-offsets.h: asm offsets for aarch64 3 | ***************************************************************************** 4 | * Copyright (C) 2014-2022 x264 project 5 | * 6 | * Authors: Janne Grunau 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_AARCH64_ASM_OFFSETS_H 27 | #define X264_AARCH64_ASM_OFFSETS_H 28 | 29 | #define CABAC_I_LOW 0x00 30 | #define CABAC_I_RANGE 0x04 31 | #define CABAC_I_QUEUE 0x08 32 | #define CABAC_I_BYTES_OUTSTANDING 0x0c 33 | #define CABAC_P_START 0x10 34 | #define CABAC_P 0x18 35 | #define CABAC_P_END 0x20 36 | #define CABAC_F8_BITS_ENCODED 0x30 37 | #define CABAC_STATE 0x34 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /x264c/external/x264/common/opencl/weightp.cl: -------------------------------------------------------------------------------- 1 | /* Weightp filter a downscaled image into a temporary output buffer. 2 | * This kernel is launched once for each scale. 3 | * 4 | * Launch dimensions: width x height (in pixels) 5 | */ 6 | kernel void weightp_scaled_images( read_only image2d_t in_plane, 7 | write_only image2d_t out_plane, 8 | uint offset, 9 | uint scale, 10 | uint denom ) 11 | { 12 | int gx = get_global_id( 0 ); 13 | int gy = get_global_id( 1 ); 14 | uint4 input_val; 15 | uint4 output_val; 16 | 17 | input_val = read_imageui( in_plane, sampler, (int2)(gx, gy)); 18 | output_val = (uint4)(offset) + ( ( ((uint4)(scale)) * input_val ) >> ((uint4)(denom)) ); 19 | write_imageui( out_plane, (int2)(gx, gy), output_val ); 20 | } 21 | 22 | /* Weightp filter for the half-pel interpolated image 23 | * 24 | * Launch dimensions: width x height (in pixels) 25 | */ 26 | kernel void weightp_hpel( read_only image2d_t in_plane, 27 | write_only image2d_t out_plane, 28 | uint offset, 29 | uint scale, 30 | uint denom ) 31 | { 32 | int gx = get_global_id( 0 ); 33 | int gy = get_global_id( 1 ); 34 | uint input_val; 35 | uint output_val; 36 | 37 | input_val = read_imageui( in_plane, sampler, (int2)(gx, gy)).s0; 38 | //Unpack 39 | uint4 temp; 40 | temp.s0 = input_val & 0x00ff; temp.s1 = (input_val >> 8) & 0x00ff; 41 | temp.s2 = (input_val >> 16) & 0x00ff; temp.s3 = (input_val >> 24) & 0x00ff; 42 | 43 | temp = (uint4)(offset) + ( ( ((uint4)(scale)) * temp ) >> ((uint4)(denom)) ); 44 | 45 | //Pack 46 | output_val = temp.s0 | (temp.s1 << 8) | (temp.s2 << 16) | (temp.s3 << 24); 47 | write_imageui( out_plane, (int2)(gx, gy), output_val ); 48 | } 49 | -------------------------------------------------------------------------------- /x264c/external/x264/common/common.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * common.c: misc common functions 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2022 x264 project 5 | * 6 | * Authors: Loren Merritt 7 | * Laurent Aimar 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 22 | * 23 | * This program is also available under a commercial proprietary license. 24 | * For more information, contact us at licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #include "common.h" 28 | 29 | /**************************************************************************** 30 | * x264_log: 31 | ****************************************************************************/ 32 | void x264_log( x264_t *h, int i_level, const char *psz_fmt, ... ) 33 | { 34 | if( !h || i_level <= h->param.i_log_level ) 35 | { 36 | va_list arg; 37 | va_start( arg, psz_fmt ); 38 | if( !h ) 39 | x264_log_default( NULL, i_level, psz_fmt, arg ); 40 | else 41 | h->param.pf_log( h->param.p_log_private, i_level, psz_fmt, arg ); 42 | va_end( arg ); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /ycbcr.go: -------------------------------------------------------------------------------- 1 | package x264 2 | 3 | import ( 4 | "image" 5 | "image/color" 6 | "image/draw" 7 | 8 | "github.com/gen2brain/x264-go/yuv" 9 | ) 10 | 11 | // YCbCr is an in-memory image of Y'CbCr colors. 12 | type YCbCr struct { 13 | *image.YCbCr 14 | } 15 | 16 | // NewYCbCr returns a new YCbCr image with the given bounds and subsample ratio. 17 | func NewYCbCr(r image.Rectangle) *YCbCr { 18 | return &YCbCr{image.NewYCbCr(r, image.YCbCrSubsampleRatio420)} 19 | } 20 | 21 | // Set sets pixel color. 22 | func (p *YCbCr) Set(x, y int, c color.Color) { 23 | p.setYCbCr(x, y, p.ColorModel().Convert(c).(color.YCbCr)) 24 | } 25 | 26 | func (p *YCbCr) setYCbCr(x, y int, c color.YCbCr) { 27 | if !image.Pt(x, y).In(p.Rect) { 28 | return 29 | } 30 | 31 | yi := p.YOffset(x, y) 32 | ci := p.COffset(x, y) 33 | 34 | p.Y[yi] = c.Y 35 | p.Cb[ci] = c.Cb 36 | p.Cr[ci] = c.Cr 37 | } 38 | 39 | // ToYCbCrDraw converts image.Image to YCbCr. 40 | func (p *YCbCr) ToYCbCrDraw(src image.Image) { 41 | bounds := src.Bounds() 42 | draw.Draw(p, bounds, src, bounds.Min, draw.Src) 43 | } 44 | 45 | // ToYCbCrColor converts image.Image to YCbCr. 46 | func (p *YCbCr) ToYCbCrColor(src image.Image) { 47 | bounds := src.Bounds() 48 | 49 | for row := 0; row < bounds.Max.Y; row++ { 50 | for col := 0; col < bounds.Max.X; col++ { 51 | r, g, b, _ := src.At(col, row).RGBA() 52 | y, cb, cr := color.RGBToYCbCr(uint8(r), uint8(g), uint8(b)) 53 | 54 | p.Y[p.YOffset(col, row)] = y 55 | p.Cb[p.COffset(col, row)] = cb 56 | p.Cr[p.COffset(col, row)] = cr 57 | } 58 | } 59 | } 60 | 61 | // ToYCbCr converts image.Image to YCbCr. 62 | func (p *YCbCr) ToYCbCr(src image.Image) { 63 | bounds := src.Bounds() 64 | width := bounds.Dx() 65 | height := bounds.Dy() 66 | 67 | lumaSize := int32(width * height) 68 | chromaSize := int32(width*height) / 4 69 | 70 | yuvProc := yuv.NewYuvImgProcessor(width, height) 71 | yCbCr := yuvProc.Process(src.(*image.RGBA)).Get() 72 | 73 | p.Y = yCbCr[:lumaSize] 74 | p.Cb = yCbCr[lumaSize : lumaSize+chromaSize] 75 | p.Cr = yCbCr[lumaSize+chromaSize:] 76 | } 77 | -------------------------------------------------------------------------------- /x264c/x264c_cgo.go: -------------------------------------------------------------------------------- 1 | //go:build !extlib 2 | // +build !extlib 3 | 4 | package x264c 5 | 6 | /* 7 | #cgo android LDFLAGS: -lm 8 | #cgo windows LDFLAGS: 9 | #cgo linux,!android LDFLAGS: -lpthread -lm 10 | #cgo darwin LDFLAGS: -lpthread -lm 11 | 12 | #cgo linux,386 CFLAGS: -DSYS_LINUX=1 -DARCH_X86=1 -DHAVE_POSIXTHREAD=1 -DSTACK_ALIGNMENT=64 -DHAVE_MALLOC_H=1 -DHAVE_CPU_COUNT=1 -DTHP=1 13 | #cgo linux,amd64 CFLAGS: -DSYS_LINUX=1 -DARCH_X86_64=1 -DHAVE_POSIXTHREAD=1 -DSTACK_ALIGNMENT=64 -DHAVE_MALLOC_H=1 -DHAVE_CPU_COUNT=1 -DTHP=1 14 | #cgo linux,!android,arm CFLAGS: -DSYS_LINUX=1 -DARCH_ARM=1 -DHAVE_POSIXTHREAD=1 -DSTACK_ALIGNMENT=4 -DHAVE_MALLOC_H=1 -DHAVE_CPU_COUNT=1 -DTHP=1 15 | #cgo linux,!android,arm64 CFLAGS: -DSYS_LINUX=1 -DARCH_AARCH64=0 -DHAVE_POSIXTHREAD=1 -DSTACK_ALIGNMENT=16 -DHAVE_MALLOC_H=1 -DHAVE_CPU_COUNT=1 -DTHP=1 16 | #cgo windows,386 CFLAGS: -DSYS_WINDOWS=1 -DARCH_X86=1 -DHAVE_WIN32THREAD=1 -DSTACK_ALIGNMENT=64 -DHAVE_MALLOC_H=0 -DHAVE_CPU_COUNT=0 -DTHP=0 17 | #cgo windows,amd64 CFLAGS: -DSYS_WINDOWS=1 -DARCH_X86_64=1 -DHAVE_WIN32THREAD=1 -DSTACK_ALIGNMENT=16 -DHAVE_MALLOC_H=0 -DHAVE_CPU_COUNT=0 -DTHP=0 18 | #cgo darwin,amd64 CFLAGS: -DSYS_MACOSX=1 -DARCH_X86_64=1 -DHAVE_POSIXTHREAD=1 -DSTACK_ALIGNMENT=16 -DHAVE_MALLOC_H=0 -DHAVE_CPU_COUNT=0 -DTHP=1 19 | #cgo android,arm CFLAGS: -DSYS_LINUX=1 -DARCH_ARM=1 -DHAVE_THREAD=1 -DHAVE_POSIXTHREAD=1 -DSTACK_ALIGNMENT=4 -DHAVE_MALLOC_H=1 -DHAVE_CPU_COUNT=0 -DTHP=1 20 | #cgo android,arm64 CFLAGS: -DSYS_LINUX=1 -DARCH_AARCH64=1 -DHAVE_THREAD=1 -DHAVE_POSIXTHREAD=1 -DSTACK_ALIGNMENT=16 -DHAVE_MALLOC_H=1 -DHAVE_CPU_COUNT=1 -DTHP=1 21 | 22 | #cgo CFLAGS: -std=gnu99 -Iexternal/x264 -D_GNU_SOURCE -fomit-frame-pointer -Wshadow -O3 23 | #cgo CFLAGS: -DHAVE_THREAD=1 -DHAVE_LOG2F=1 -DHAVE_STRTOK_R=1 -DHAVE_MMAP=1 -DHAVE_GPL=1 -DHAVE_INTERLACED=1 24 | #cgo CFLAGS: -DHAVE_SWSCALE=0 -DHAVE_LAVF=0 -DHAVE_AVS=0 -DUSE_AVXSYNTH=0 -DHAVE_VECTOREXT=1 -DHAVE_BITDEPTH8=1 -DHAVE_BITDEPTH10=0 25 | #cgo CFLAGS: -DHIGH_BIT_DEPTH=0 -DHAVE_OPENCL=0 -DHAVE_ALTIVEC=0 -DHAVE_ALTIVEC_H=0 -DHAVE_FFMS=0 -DHAVE_GPAC=0 -DHAVE_LSMASH=0 26 | #cgo CFLAGS: -DBIT_DEPTH=8 -DX264_BIT_DEPTH=8 -DX264_GPL=1 -DX264_INTERLACED=1 -DX264_CHROMA_FORMAT=0 27 | */ 28 | import "C" 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## x264-go 2 | [![Build Status](https://github.com/gen2brain/x264-go/actions/workflows/build.yml/badge.svg)](https://github.com/gen2brain/x264-go/actions) 3 | [![GoDoc](https://godoc.org/github.com/gen2brain/x264-go?status.svg)](https://godoc.org/github.com/gen2brain/x264-go) 4 | [![Go Report Card](https://goreportcard.com/badge/github.com/gen2brain/x264-go?branch=master)](https://goreportcard.com/report/github.com/gen2brain/x264-go) 5 | 6 | `x264-go` provides H.264/MPEG-4 AVC codec encoder based on [x264](https://www.videolan.org/developers/x264.html) library. 7 | 8 | C source code is included in package. If you want to use external shared/static library (i.e. built with asm and/or OpenCL) use `-tags extlib` 9 | 10 | ### Installation 11 | 12 | go get -u github.com/gen2brain/x264-go 13 | 14 | ### Build tags 15 | 16 | * `extlib` - use external x264 library 17 | * `pkgconfig` - enable pkg-config (used with extlib) 18 | 19 | 20 | ### Examples 21 | 22 | See [screengrab](https://github.com/gen2brain/x264-go/blob/master/examples/screengrab/screengrab.go) example. 23 | 24 | ### Usage 25 | 26 | ```go 27 | package main 28 | 29 | import ( 30 | "bytes" 31 | "image" 32 | "image/color" 33 | "image/draw" 34 | 35 | "github.com/gen2brain/x264-go" 36 | ) 37 | 38 | func main() { 39 | buf := bytes.NewBuffer(make([]byte, 0)) 40 | 41 | opts := &x264.Options{ 42 | Width: 640, 43 | Height: 480, 44 | FrameRate: 25, 45 | Tune: "zerolatency", 46 | Preset: "veryfast", 47 | Profile: "baseline", 48 | LogLevel: x264.LogDebug, 49 | } 50 | 51 | enc, err := x264.NewEncoder(buf, opts) 52 | if err != nil { 53 | panic(err) 54 | } 55 | 56 | img := x264.NewYCbCr(image.Rect(0, 0, opts.Width, opts.Height)) 57 | draw.Draw(img, img.Bounds(), image.Black, image.ZP, draw.Src) 58 | 59 | for i := 0; i < opts.Width/2; i++ { 60 | img.Set(i, opts.Height/2, color.RGBA{255, 0, 0, 255}) 61 | 62 | err = enc.Encode(img) 63 | if err != nil { 64 | panic(err) 65 | } 66 | } 67 | 68 | err = enc.Flush() 69 | if err != nil { 70 | panic(err) 71 | } 72 | 73 | err = enc.Close() 74 | if err != nil { 75 | panic(err) 76 | } 77 | } 78 | ``` 79 | 80 | ## More 81 | 82 | For AAC encoder see [aac-go](https://github.com/gen2brain/aac-go). 83 | -------------------------------------------------------------------------------- /x264c/external/x264/common/threadpool.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * threadpool.h: thread pooling 3 | ***************************************************************************** 4 | * Copyright (C) 2010-2022 x264 project 5 | * 6 | * Authors: Steven Walters 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_THREADPOOL_H 27 | #define X264_THREADPOOL_H 28 | 29 | typedef struct x264_threadpool_t x264_threadpool_t; 30 | 31 | #if HAVE_THREAD 32 | #define x264_threadpool_init x264_template(threadpool_init) 33 | X264_API int x264_threadpool_init( x264_threadpool_t **p_pool, int threads ); 34 | #define x264_threadpool_run x264_template(threadpool_run) 35 | X264_API void x264_threadpool_run( x264_threadpool_t *pool, void *(*func)(void *), void *arg ); 36 | #define x264_threadpool_wait x264_template(threadpool_wait) 37 | X264_API void *x264_threadpool_wait( x264_threadpool_t *pool, void *arg ); 38 | #define x264_threadpool_delete x264_template(threadpool_delete) 39 | X264_API void x264_threadpool_delete( x264_threadpool_t *pool ); 40 | #else 41 | #define x264_threadpool_init(p,t) -1 42 | #define x264_threadpool_run(p,f,a) 43 | #define x264_threadpool_wait(p,a) NULL 44 | #define x264_threadpool_delete(p) 45 | #endif 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /examples/screengrab/go.sum: -------------------------------------------------------------------------------- 1 | github.com/gen2brain/shm v0.0.0-20200228170931-49f9650110c5/go.mod h1:uF6rMu/1nvu+5DpiRLwusA6xB8zlkNoGzKn8lmYONUo= 2 | github.com/gen2brain/shm v0.0.0-20221026125803-c33c9e32b1c8 h1:u4/UVF0sNxlqDwCptjIUTUkZW4UoZDrcHzvd2kNnF/k= 3 | github.com/gen2brain/shm v0.0.0-20221026125803-c33c9e32b1c8/go.mod h1:uF6rMu/1nvu+5DpiRLwusA6xB8zlkNoGzKn8lmYONUo= 4 | github.com/gen2brain/x264-go v0.2.3 h1:sregA+Bm656eQrUyFXT1/L6FWoE9Bh2j4AvZN8TCqvg= 5 | github.com/gen2brain/x264-go v0.2.3/go.mod h1:E8NzifRRlIjgPiHeBrd2gDNl0aajri6uNc117BROuwA= 6 | github.com/gen2brain/x264-go/x264c v0.0.0-20221204084822-82ee2951dea2/go.mod h1:MUMv+ZURlTO3qH8QAt2gxiIY5X4NMaxObz2ImZOMvyA= 7 | github.com/gen2brain/x264-go/x264c v0.0.0-20221224044516-9a74c944fe06 h1:5TlL34sEh7ayVSPodg2u7FI245aNlC0ZmjhxlwWIFZ8= 8 | github.com/gen2brain/x264-go/x264c v0.0.0-20221224044516-9a74c944fe06/go.mod h1:MUMv+ZURlTO3qH8QAt2gxiIY5X4NMaxObz2ImZOMvyA= 9 | github.com/gen2brain/x264-go/yuv v0.0.0-20221204084822-82ee2951dea2/go.mod h1:PzzJntdOaVt4Gc37fNaEXpqmhKkUgd/xqyPMUfx+FQc= 10 | github.com/gen2brain/x264-go/yuv v0.0.0-20221224044516-9a74c944fe06 h1:F9tya2kVp2cYBHY0NjuhYEqfsULYuSxqeqk3g5c3eDI= 11 | github.com/gen2brain/x264-go/yuv v0.0.0-20221224044516-9a74c944fe06/go.mod h1:PzzJntdOaVt4Gc37fNaEXpqmhKkUgd/xqyPMUfx+FQc= 12 | github.com/jezek/xgb v0.0.0-20210312150743-0e0f116e1240/go.mod h1:3P4UH/k22rXyHIJD2w4h2XMqPX4Of/eySEZq9L6wqc4= 13 | github.com/jezek/xgb v1.1.0 h1:wnpxJzP1+rkbGclEkmwpVFQWpuE2PUGNUzP8SbfFobk= 14 | github.com/jezek/xgb v1.1.0/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk= 15 | github.com/kbinani/screenshot v0.0.0-20210720154843-7d3a670d8329 h1:qq2nCpSrXrmvDGRxW0ruW9BVEV1CN2a9YDOExdt+U0o= 16 | github.com/kbinani/screenshot v0.0.0-20210720154843-7d3a670d8329/go.mod h1:2VPVQDR4wO7KXHwP+DAypEy67rXf+okUx2zjgpCxZw4= 17 | github.com/lxn/win v0.0.0-20210218163916-a377121e959e h1:H+t6A/QJMbhCSEH5rAuRxh+CtW96g0Or0Fxa9IKr4uc= 18 | github.com/lxn/win v0.0.0-20210218163916-a377121e959e/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk= 19 | golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 20 | golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= 21 | golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 22 | -------------------------------------------------------------------------------- /x264c/external/x264/common/rectangle.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * rectangle.c: rectangle filling 3 | ***************************************************************************** 4 | * Copyright (C) 2010-2022 x264 project 5 | * 6 | * Authors: Fiona Glaser 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #include "common.h" 27 | 28 | #define CACHE_FUNC(name,size,width,height)\ 29 | static void macroblock_cache_##name##_##width##_##height( void *target, uint32_t val )\ 30 | {\ 31 | x264_macroblock_cache_rect( target, width*size, height, size, val );\ 32 | } 33 | 34 | #define CACHE_FUNCS(name,size)\ 35 | CACHE_FUNC(name,size,4,4)\ 36 | CACHE_FUNC(name,size,2,4)\ 37 | CACHE_FUNC(name,size,4,2)\ 38 | CACHE_FUNC(name,size,2,2)\ 39 | CACHE_FUNC(name,size,2,1)\ 40 | CACHE_FUNC(name,size,1,2)\ 41 | CACHE_FUNC(name,size,1,1)\ 42 | void (*x264_cache_##name##_func_table[10])(void *, uint32_t) =\ 43 | {\ 44 | macroblock_cache_##name##_1_1,\ 45 | macroblock_cache_##name##_2_1,\ 46 | macroblock_cache_##name##_1_2,\ 47 | macroblock_cache_##name##_2_2,\ 48 | NULL,\ 49 | macroblock_cache_##name##_4_2,\ 50 | NULL,\ 51 | macroblock_cache_##name##_2_4,\ 52 | NULL,\ 53 | macroblock_cache_##name##_4_4\ 54 | };\ 55 | 56 | CACHE_FUNCS(mv, 4) 57 | CACHE_FUNCS(mvd, 2) 58 | CACHE_FUNCS(ref, 1) 59 | -------------------------------------------------------------------------------- /x264c/external/x264/common/cpu.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * cpu.h: cpu detection 3 | ***************************************************************************** 4 | * Copyright (C) 2004-2022 x264 project 5 | * 6 | * Authors: Loren Merritt 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_CPU_H 27 | #define X264_CPU_H 28 | 29 | X264_API uint32_t x264_cpu_detect( void ); 30 | X264_API int x264_cpu_num_processors( void ); 31 | void x264_cpu_emms( void ); 32 | void x264_cpu_sfence( void ); 33 | #if HAVE_MMX 34 | /* There is no way to forbid the compiler from using float instructions 35 | * before the emms so miscompilation could theoretically occur in the 36 | * unlikely event that the compiler reorders emms and float instructions. */ 37 | #if HAVE_X86_INLINE_ASM 38 | /* Clobbering memory makes the compiler less likely to reorder code. */ 39 | #define x264_emms() asm volatile( "emms":::"memory","st","st(1)","st(2)", \ 40 | "st(3)","st(4)","st(5)","st(6)","st(7)" ) 41 | #else 42 | #define x264_emms() x264_cpu_emms() 43 | #endif 44 | #else 45 | #define x264_emms() 46 | #endif 47 | #define x264_sfence x264_cpu_sfence 48 | 49 | typedef struct 50 | { 51 | const char *name; 52 | uint32_t flags; 53 | } x264_cpu_name_t; 54 | X264_API extern const x264_cpu_name_t x264_cpu_names[]; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /x264c/external/x264/common/ppc/quant.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * quant.h: ppc quantization 3 | ***************************************************************************** 4 | * Copyright (C) 2007-2022 x264 project 5 | * 6 | * Authors: Guillaume Poirier 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_PPC_QUANT_H 27 | #define X264_PPC_QUANT_H 28 | 29 | #define x264_quant_4x4x4_altivec x264_template(quant_4x4x4_altivec) 30 | int x264_quant_4x4x4_altivec( int16_t dct[4][16], uint16_t mf[16], uint16_t bias[16] ); 31 | #define x264_quant_4x4_altivec x264_template(quant_4x4_altivec) 32 | int x264_quant_4x4_altivec( int16_t dct[16], uint16_t mf[16], uint16_t bias[16] ); 33 | #define x264_quant_8x8_altivec x264_template(quant_8x8_altivec) 34 | int x264_quant_8x8_altivec( int16_t dct[64], uint16_t mf[64], uint16_t bias[64] ); 35 | 36 | #define x264_quant_4x4_dc_altivec x264_template(quant_4x4_dc_altivec) 37 | int x264_quant_4x4_dc_altivec( int16_t dct[16], int mf, int bias ); 38 | #define x264_quant_2x2_dc_altivec x264_template(quant_2x2_dc_altivec) 39 | int x264_quant_2x2_dc_altivec( int16_t dct[4], int mf, int bias ); 40 | 41 | #define x264_dequant_4x4_altivec x264_template(dequant_4x4_altivec) 42 | void x264_dequant_4x4_altivec( int16_t dct[16], int dequant_mf[6][16], int i_qp ); 43 | #define x264_dequant_8x8_altivec x264_template(dequant_8x8_altivec) 44 | void x264_dequant_8x8_altivec( int16_t dct[64], int dequant_mf[6][64], int i_qp ); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /x264c/external/x264/AUTHORS: -------------------------------------------------------------------------------- 1 | # Contributors to x264 2 | # 3 | # The format of this file was inspired by the Linux kernel CREDITS file. 4 | # Authors are listed alphabetically. 5 | # 6 | # The fields are: name (N), email (E), web-address (W), CVS account login (C), 7 | # PGP key ID and fingerprint (P), description (D), and snail-mail address (S). 8 | 9 | N: Alex Izvorski 10 | E: aizvorski AT gmail DOT com 11 | D: x86 asm (sse2) 12 | 13 | N: Alex Wright 14 | E: alexw0885 AT gmail DOT com 15 | D: Motion estimation (subpel and mixed refs) 16 | D: B-RDO 17 | 18 | N: bobololo 19 | D: Avisynth input 20 | D: MP4 muxing 21 | 22 | N: Christian Heine 23 | E: sennindemokrit AT gmx DOT net 24 | D: x86 asm 25 | 26 | N: David Wolstencroft 27 | D: Altivec optimizations 28 | 29 | N: Eric Petit 30 | E: eric.petit AT lapsus DOT org 31 | C: titer 32 | D: Altivec asm 33 | D: BeOS and MacOS X ports. 34 | S: France 35 | 36 | N: Fiona Glaser 37 | E: fiona AT x264 DOT com 38 | D: Maintainer 39 | D: All areas of encoder analysis and algorithms 40 | D: Motion estimation, rate control, macroblock & frame decisions, RDO, etc 41 | D: x86 asm 42 | S: USA 43 | 44 | N: Gabriel Bouvigne 45 | E: bouvigne AT mp3-tech DOT org 46 | D: 2pass VBV 47 | 48 | N: Guillaume Poirier 49 | E: gpoirier CHEZ mplayerhq POINT hu 50 | D: Altivec optimizations 51 | S: Brittany, France 52 | 53 | N: Henrik Gramner 54 | E: henrik AT gramner DOT com 55 | D: 4:2:2 chroma subsampling, x86 asm, Windows improvements, bugfixes 56 | S: Sweden 57 | 58 | N: Laurent Aimar 59 | E: fenrir AT videolan DOT org 60 | C: fenrir 61 | D: Initial import, former maintainer 62 | D: x86 asm (mmx/mmx2) 63 | S: France 64 | 65 | N: Loren Merritt 66 | E: pengvado AT akuvian DOT org 67 | C: pengvado 68 | D: Maintainer 69 | D: All areas of encoder analysis and algorithms 70 | D: Motion estimation, rate control, macroblock & frame decisions, RDO, etc 71 | D: Multithreading 72 | D: x86 asm 73 | S: USA 74 | 75 | N: Mans Rullgard 76 | E: mru AT mansr DOT com 77 | C: mru 78 | D: Rate control 79 | S: Southampton, UK 80 | 81 | N: Michael Niedermayer 82 | E: michaelni AT gmx DOT at 83 | D: Rate control 84 | 85 | N: Mike Matsnev 86 | E: mike AT po DOT cs DOT msu DOT su 87 | D: Matroska muxing 88 | 89 | N: Min Chen 90 | E: chenm001 AT 163 DOT com 91 | C: chenm001 92 | D: Win32/VC 6.0 port 93 | D: gcc asm to nasm conversion 94 | S: China 95 | 96 | N: Radek Czyz 97 | E: radoslaw AT syskin DOT cjb DOT net 98 | D: Cached motion compensation 99 | 100 | -------------------------------------------------------------------------------- /x264c/external/x264/encoder/slicetype-cl.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * slicetype-cl.h: OpenCL slicetype decision code (lowres lookahead) 3 | ***************************************************************************** 4 | * Copyright (C) 2017-2022 x264 project 5 | * 6 | * Authors: Anton Mitrofanov 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_ENCODER_SLICETYPE_CL_H 27 | #define X264_ENCODER_SLICETYPE_CL_H 28 | 29 | #define x264_opencl_lowres_init x264_template(opencl_lowres_init) 30 | int x264_opencl_lowres_init( x264_t *h, x264_frame_t *fenc, int lambda ); 31 | #define x264_opencl_motionsearch x264_template(opencl_motionsearch) 32 | int x264_opencl_motionsearch( x264_t *h, x264_frame_t **frames, int b, int ref, int b_islist1, int lambda, const x264_weight_t *w ); 33 | #define x264_opencl_finalize_cost x264_template(opencl_finalize_cost) 34 | int x264_opencl_finalize_cost( x264_t *h, int lambda, x264_frame_t **frames, int p0, int p1, int b, int dist_scale_factor ); 35 | #define x264_opencl_precalculate_frame_cost x264_template(opencl_precalculate_frame_cost) 36 | int x264_opencl_precalculate_frame_cost( x264_t *h, x264_frame_t **frames, int lambda, int p0, int p1, int b ); 37 | #define x264_opencl_flush x264_template(opencl_flush) 38 | void x264_opencl_flush( x264_t *h ); 39 | #define x264_opencl_slicetype_prep x264_template(opencl_slicetype_prep) 40 | void x264_opencl_slicetype_prep( x264_t *h, x264_frame_t **frames, int num_frames, int lambda ); 41 | #define x264_opencl_slicetype_end x264_template(opencl_slicetype_end) 42 | void x264_opencl_slicetype_end( x264_t *h ); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /x264c/external/x264/common/aarch64/asm-offsets.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * asm-offsets.c: check asm offsets for aarch64 3 | ***************************************************************************** 4 | * Copyright (C) 2014-2022 x264 project 5 | * 6 | * Authors: Janne Grunau 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #include "common/common.h" 27 | #include "asm-offsets.h" 28 | 29 | #define STATIC_ASSERT(name, x) int assert_##name[2 * !!(x) - 1] 30 | 31 | #define X264_CHECK_OFFSET(s, m, o) struct check_##s##_##m \ 32 | { \ 33 | STATIC_ASSERT(offset_##m, offsetof(s, m) == o); \ 34 | } 35 | 36 | #define X264_CHECK_REL_OFFSET(s, a, type, b) struct check_##s##_##a##_##b \ 37 | { \ 38 | STATIC_ASSERT(rel_offset_##a##_##b, offsetof(s, a) + sizeof(type) == offsetof(s, b)); \ 39 | } 40 | 41 | 42 | X264_CHECK_OFFSET(x264_cabac_t, i_low, CABAC_I_LOW); 43 | X264_CHECK_OFFSET(x264_cabac_t, i_range, CABAC_I_RANGE); 44 | X264_CHECK_OFFSET(x264_cabac_t, i_queue, CABAC_I_QUEUE); 45 | X264_CHECK_OFFSET(x264_cabac_t, i_bytes_outstanding, CABAC_I_BYTES_OUTSTANDING); 46 | X264_CHECK_OFFSET(x264_cabac_t, p_start, CABAC_P_START); 47 | X264_CHECK_OFFSET(x264_cabac_t, p, CABAC_P); 48 | X264_CHECK_OFFSET(x264_cabac_t, p_end, CABAC_P_END); 49 | X264_CHECK_OFFSET(x264_cabac_t, f8_bits_encoded, CABAC_F8_BITS_ENCODED); 50 | X264_CHECK_OFFSET(x264_cabac_t, state, CABAC_STATE); 51 | 52 | // the aarch64 asm makes following additional assumptions about the x264_cabac_t 53 | // memory layout 54 | 55 | X264_CHECK_REL_OFFSET(x264_cabac_t, i_low, int, i_range); 56 | X264_CHECK_REL_OFFSET(x264_cabac_t, i_queue, int, i_bytes_outstanding); 57 | -------------------------------------------------------------------------------- /x264c/external/x264/encoder/analyse.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * analyse.h: macroblock analysis 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2022 x264 project 5 | * 6 | * Authors: Laurent Aimar 7 | * Loren Merritt 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 22 | * 23 | * This program is also available under a commercial proprietary license. 24 | * For more information, contact us at licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #ifndef X264_ENCODER_ANALYSE_H 28 | #define X264_ENCODER_ANALYSE_H 29 | 30 | #define x264_analyse_init_costs x264_template(analyse_init_costs) 31 | int x264_analyse_init_costs( x264_t *h ); 32 | #define x264_analyse_free_costs x264_template(analyse_free_costs) 33 | void x264_analyse_free_costs( x264_t *h ); 34 | #define x264_analyse_weight_frame x264_template(analyse_weight_frame) 35 | void x264_analyse_weight_frame( x264_t *h, int end ); 36 | #define x264_macroblock_analyse x264_template(macroblock_analyse) 37 | void x264_macroblock_analyse( x264_t *h ); 38 | #define x264_slicetype_decide x264_template(slicetype_decide) 39 | void x264_slicetype_decide( x264_t *h ); 40 | 41 | #define x264_slicetype_analyse x264_template(slicetype_analyse) 42 | void x264_slicetype_analyse( x264_t *h, int intra_minigop ); 43 | 44 | #define x264_lookahead_init x264_template(lookahead_init) 45 | int x264_lookahead_init( x264_t *h, int i_slicetype_length ); 46 | #define x264_lookahead_is_empty x264_template(lookahead_is_empty) 47 | int x264_lookahead_is_empty( x264_t *h ); 48 | #define x264_lookahead_put_frame x264_template(lookahead_put_frame) 49 | void x264_lookahead_put_frame( x264_t *h, x264_frame_t *frame ); 50 | #define x264_lookahead_get_frames x264_template(lookahead_get_frames) 51 | void x264_lookahead_get_frames( x264_t *h ); 52 | #define x264_lookahead_delete x264_template(lookahead_delete) 53 | void x264_lookahead_delete( x264_t *h ); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /x264c/external/x264/common/mips/quant.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * quant.h: msa quantization and level-run 3 | ***************************************************************************** 4 | * Copyright (C) 2015-2022 x264 project 5 | * 6 | * Authors: Rishikesh More 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_MIPS_QUANT_H 27 | #define X264_MIPS_QUANT_H 28 | 29 | #define x264_dequant_4x4_msa x264_template(dequant_4x4_msa) 30 | void x264_dequant_4x4_msa( int16_t *p_dct, int32_t pi_dequant_mf[6][16], 31 | int32_t i_qp ); 32 | #define x264_dequant_8x8_msa x264_template(dequant_8x8_msa) 33 | void x264_dequant_8x8_msa( int16_t *p_dct, int32_t pi_dequant_mf[6][64], 34 | int32_t i_qp ); 35 | #define x264_dequant_4x4_dc_msa x264_template(dequant_4x4_dc_msa) 36 | void x264_dequant_4x4_dc_msa( int16_t *p_dct, int32_t pi_dequant_mf[6][16], 37 | int32_t i_qp ); 38 | #define x264_quant_4x4_msa x264_template(quant_4x4_msa) 39 | int32_t x264_quant_4x4_msa( int16_t *p_dct, uint16_t *p_mf, uint16_t *p_bias ); 40 | #define x264_quant_4x4x4_msa x264_template(quant_4x4x4_msa) 41 | int32_t x264_quant_4x4x4_msa( int16_t p_dct[4][16], 42 | uint16_t pu_mf[16], uint16_t pu_bias[16] ); 43 | #define x264_quant_8x8_msa x264_template(quant_8x8_msa) 44 | int32_t x264_quant_8x8_msa( int16_t *p_dct, uint16_t *p_mf, uint16_t *p_bias ); 45 | #define x264_quant_4x4_dc_msa x264_template(quant_4x4_dc_msa) 46 | int32_t x264_quant_4x4_dc_msa( int16_t *p_dct, int32_t i_mf, int32_t i_bias ); 47 | #define x264_coeff_last64_msa x264_template(coeff_last64_msa) 48 | int32_t x264_coeff_last64_msa( int16_t *p_src ); 49 | #define x264_coeff_last16_msa x264_template(coeff_last16_msa) 50 | int32_t x264_coeff_last16_msa( int16_t *p_src ); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /x264c/external/x264/common/arm/bitstream-a.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * bitstream-a.S: arm bitstream functions 3 | ***************************************************************************** 4 | * Copyright (C) 2014-2022 x264 project 5 | * 6 | * Authors: Janne Grunau 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #include "asm.S" 27 | 28 | function nal_escape_neon 29 | push {r4-r5,lr} 30 | vmov.u8 q0, #0xff 31 | vmov.u8 q8, #4 32 | mov r3, #3 33 | subs lr, r1, r2 34 | beq 99f 35 | 0: 36 | cmn lr, #15 37 | blt 16f 38 | mov r1, r2 39 | b 100f 40 | 16: 41 | vld1.8 {q1}, [r1]! 42 | vext.8 q2, q0, q1, #14 43 | vext.8 q3, q0, q1, #15 44 | vcgt.u8 q11, q8, q1 45 | vceq.u8 q9, q2, #0 46 | vceq.u8 q10, q3, #0 47 | vand q9, q9, q11 48 | vand q9, q9, q10 49 | vshrn.u16 d22, q9, #4 50 | vmov ip, lr, d22 51 | orrs ip, ip, lr 52 | beq 16f 53 | mov lr, #-16 54 | 100: 55 | vmov.u8 r5, d1[6] 56 | vmov.u8 r4, d1[7] 57 | orr r5, r4, r5, lsl #8 58 | 101: 59 | ldrb r4, [r1, lr] 60 | orr ip, r4, r5, lsl #16 61 | cmp ip, #3 62 | bhi 102f 63 | strb r3, [r0], #1 64 | orr r5, r3, r5, lsl #8 65 | 102: 66 | adds lr, lr, #1 67 | strb r4, [r0], #1 68 | orr r5, r4, r5, lsl #8 69 | blt 101b 70 | subs lr, r1, r2 71 | lsr ip, r5, #8 72 | vmov.u8 d1[6], ip 73 | vmov.u8 d1[7], r5 74 | blt 0b 75 | 76 | pop {r4-r5,pc} 77 | 16: 78 | subs lr, r1, r2 79 | vst1.8 {q1}, [r0]! 80 | vmov q0, q1 81 | blt 0b 82 | 99: 83 | pop {r4-r5,pc} 84 | endfunc 85 | -------------------------------------------------------------------------------- /x264c/external/x264/common/aarch64/bitstream-a.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * bitstream-a.S: aarch64 bitstream functions 3 | ***************************************************************************** 4 | * Copyright (C) 2014-2022 x264 project 5 | * 6 | * Authors: Janne Grunau 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #include "asm.S" 27 | 28 | function nal_escape_neon, export=1 29 | movi v0.16b, #0xff 30 | movi v4.16b, #4 31 | mov w3, #3 32 | subs x6, x1, x2 33 | cbz x6, 99f 34 | 0: 35 | cmn x6, #15 36 | b.lt 16f 37 | mov x1, x2 38 | b 100f 39 | 16: 40 | ld1 {v1.16b}, [x1], #16 41 | ext v2.16b, v0.16b, v1.16b, #14 42 | ext v3.16b, v0.16b, v1.16b, #15 43 | cmhi v7.16b, v4.16b, v1.16b 44 | cmeq v5.16b, v2.16b, #0 45 | cmeq v6.16b, v3.16b, #0 46 | and v5.16b, v5.16b, v7.16b 47 | and v5.16b, v5.16b, v6.16b 48 | shrn v7.8b, v5.8h, #4 49 | mov x7, v7.d[0] 50 | cbz x7, 16f 51 | mov x6, #-16 52 | 100: 53 | umov w5, v0.b[14] 54 | umov w4, v0.b[15] 55 | orr w5, w4, w5, lsl #8 56 | 101: 57 | ldrb w4, [x1, x6] 58 | orr w9, w4, w5, lsl #16 59 | cmp w9, #3 60 | b.hi 102f 61 | strb w3, [x0], #1 62 | orr w5, w3, w5, lsl #8 63 | 102: 64 | adds x6, x6, #1 65 | strb w4, [x0], #1 66 | orr w5, w4, w5, lsl #8 67 | b.lt 101b 68 | subs x6, x1, x2 69 | lsr w9, w5, #8 70 | mov v0.b[14], w9 71 | mov v0.b[15], w5 72 | b.lt 0b 73 | 74 | ret 75 | 16: 76 | subs x6, x1, x2 77 | st1 {v1.16b}, [x0], #16 78 | mov v0.16b, v1.16b 79 | b.lt 0b 80 | 99: 81 | ret 82 | endfunc 83 | -------------------------------------------------------------------------------- /x264c/external/x264/common/mips/deblock.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * deblock.h: msa deblocking 3 | ***************************************************************************** 4 | * Copyright (C) 2017-2022 x264 project 5 | * 6 | * Authors: Anton Mitrofanov 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_MIPS_DEBLOCK_H 27 | #define X264_MIPS_DEBLOCK_H 28 | 29 | #if !HIGH_BIT_DEPTH 30 | #define x264_deblock_v_luma_msa x264_template(deblock_v_luma_msa) 31 | void x264_deblock_v_luma_msa( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 32 | #define x264_deblock_h_luma_msa x264_template(deblock_h_luma_msa) 33 | void x264_deblock_h_luma_msa( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 34 | #define x264_deblock_v_chroma_msa x264_template(deblock_v_chroma_msa) 35 | void x264_deblock_v_chroma_msa( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 36 | #define x264_deblock_h_chroma_msa x264_template(deblock_h_chroma_msa) 37 | void x264_deblock_h_chroma_msa( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 38 | #define x264_deblock_v_luma_intra_msa x264_template(deblock_v_luma_intra_msa) 39 | void x264_deblock_v_luma_intra_msa( uint8_t *pix, intptr_t stride, int alpha, int beta ); 40 | #define x264_deblock_h_luma_intra_msa x264_template(deblock_h_luma_intra_msa) 41 | void x264_deblock_h_luma_intra_msa( uint8_t *pix, intptr_t stride, int alpha, int beta ); 42 | #define x264_deblock_v_chroma_intra_msa x264_template(deblock_v_chroma_intra_msa) 43 | void x264_deblock_v_chroma_intra_msa( uint8_t *pix, intptr_t stride, int alpha, int beta ); 44 | #define x264_deblock_h_chroma_intra_msa x264_template(deblock_h_chroma_intra_msa) 45 | void x264_deblock_h_chroma_intra_msa( uint8_t *pix, intptr_t stride, int alpha, int beta ); 46 | #define x264_deblock_strength_msa x264_template(deblock_strength_msa) 47 | void x264_deblock_strength_msa( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE], 48 | int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][8][4], int mvy_limit, 49 | int bframe ); 50 | #endif 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /x264c/external/x264/common/win32thread.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * win32thread.h: windows threading 3 | ***************************************************************************** 4 | * Copyright (C) 2010-2022 x264 project 5 | * 6 | * Authors: Steven Walters 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_WIN32THREAD_H 27 | #define X264_WIN32THREAD_H 28 | 29 | #include 30 | /* the following macro is used within x264 */ 31 | #undef ERROR 32 | 33 | typedef struct 34 | { 35 | void *handle; 36 | void *(*func)( void* arg ); 37 | void *arg; 38 | void **p_ret; 39 | void *ret; 40 | } x264_pthread_t; 41 | #define x264_pthread_attr_t int 42 | 43 | /* the conditional variable api for windows 6.0+ uses critical sections and not mutexes */ 44 | typedef CRITICAL_SECTION x264_pthread_mutex_t; 45 | #define X264_PTHREAD_MUTEX_INITIALIZER {0} 46 | #define x264_pthread_mutexattr_t int 47 | 48 | #if HAVE_WINRT 49 | typedef CONDITION_VARIABLE x264_pthread_cond_t; 50 | #else 51 | typedef struct 52 | { 53 | void *Ptr; 54 | } x264_pthread_cond_t; 55 | #endif 56 | #define x264_pthread_condattr_t int 57 | 58 | int x264_pthread_create( x264_pthread_t *thread, const x264_pthread_attr_t *attr, 59 | void *(*start_routine)( void* ), void *arg ); 60 | int x264_pthread_join( x264_pthread_t thread, void **value_ptr ); 61 | 62 | int x264_pthread_mutex_init( x264_pthread_mutex_t *mutex, const x264_pthread_mutexattr_t *attr ); 63 | int x264_pthread_mutex_destroy( x264_pthread_mutex_t *mutex ); 64 | int x264_pthread_mutex_lock( x264_pthread_mutex_t *mutex ); 65 | int x264_pthread_mutex_unlock( x264_pthread_mutex_t *mutex ); 66 | 67 | int x264_pthread_cond_init( x264_pthread_cond_t *cond, const x264_pthread_condattr_t *attr ); 68 | int x264_pthread_cond_destroy( x264_pthread_cond_t *cond ); 69 | int x264_pthread_cond_broadcast( x264_pthread_cond_t *cond ); 70 | int x264_pthread_cond_wait( x264_pthread_cond_t *cond, x264_pthread_mutex_t *mutex ); 71 | int x264_pthread_cond_signal( x264_pthread_cond_t *cond ); 72 | 73 | #define x264_pthread_attr_init(a) 0 74 | #define x264_pthread_attr_destroy(a) 0 75 | 76 | int x264_win32_threading_init( void ); 77 | void x264_win32_threading_destroy( void ); 78 | 79 | int x264_pthread_num_processors_np( void ); 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /x264c/external/x264/common/x86/const-a.asm: -------------------------------------------------------------------------------- 1 | ;***************************************************************************** 2 | ;* const-a.asm: x86 global constants 3 | ;***************************************************************************** 4 | ;* Copyright (C) 2010-2022 x264 project 5 | ;* 6 | ;* Authors: Loren Merritt 7 | ;* Fiona Glaser 8 | ;* 9 | ;* This program is free software; you can redistribute it and/or modify 10 | ;* it under the terms of the GNU General Public License as published by 11 | ;* the Free Software Foundation; either version 2 of the License, or 12 | ;* (at your option) any later version. 13 | ;* 14 | ;* This program is distributed in the hope that it will be useful, 15 | ;* but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ;* GNU General Public License for more details. 18 | ;* 19 | ;* You should have received a copy of the GNU General Public License 20 | ;* along with this program; if not, write to the Free Software 21 | ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 22 | ;* 23 | ;* This program is also available under a commercial proprietary license. 24 | ;* For more information, contact us at licensing@x264.com. 25 | ;***************************************************************************** 26 | 27 | %include "x86inc.asm" 28 | 29 | SECTION_RODATA 32 30 | 31 | const pb_1, times 32 db 1 32 | const hsub_mul, times 16 db 1, -1 33 | const pw_1, times 16 dw 1 34 | const pw_16, times 16 dw 16 35 | const pw_32, times 16 dw 32 36 | const pw_512, times 16 dw 512 37 | const pw_00ff, times 16 dw 0x00ff 38 | const pw_pixel_max,times 16 dw ((1 << BIT_DEPTH)-1) 39 | const pw_0to15, dw 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 40 | const pd_1, times 8 dd 1 41 | const pd_0123, dd 0,1,2,3 42 | const pd_4567, dd 4,5,6,7 43 | const deinterleave_shufd, dd 0,4,1,5,2,6,3,7 44 | const pb_unpackbd1, times 2 db 0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3 45 | const pb_unpackbd2, times 2 db 4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7 46 | 47 | const pb_01, times 8 db 0,1 48 | const pb_0, times 16 db 0 49 | const pb_a1, times 16 db 0xa1 50 | const pb_3, times 16 db 3 51 | const pb_shuf8x8c, db 0,0,0,0,2,2,2,2,4,4,4,4,6,6,6,6 52 | 53 | const pw_2, times 8 dw 2 54 | const pw_m2, times 8 dw -2 55 | const pw_4, times 8 dw 4 56 | const pw_8, times 8 dw 8 57 | const pw_64, times 8 dw 64 58 | const pw_256, times 8 dw 256 59 | const pw_32_0, times 4 dw 32 60 | times 4 dw 0 61 | const pw_8000, times 8 dw 0x8000 62 | const pw_3fff, times 8 dw 0x3fff 63 | const pw_ppppmmmm, dw 1,1,1,1,-1,-1,-1,-1 64 | const pw_ppmmppmm, dw 1,1,-1,-1,1,1,-1,-1 65 | const pw_pmpmpmpm, dw 1,-1,1,-1,1,-1,1,-1 66 | const pw_pmmpzzzz, dw 1,-1,-1,1,0,0,0,0 67 | 68 | const pd_8, times 4 dd 8 69 | const pd_32, times 4 dd 32 70 | const pd_1024, times 4 dd 1024 71 | const pd_ffff, times 4 dd 0xffff 72 | const pw_ff00, times 8 dw 0xff00 73 | 74 | const popcnt_table 75 | %assign x 0 76 | %rep 256 77 | ; population count 78 | db ((x>>0)&1)+((x>>1)&1)+((x>>2)&1)+((x>>3)&1)+((x>>4)&1)+((x>>5)&1)+((x>>6)&1)+((x>>7)&1) 79 | %assign x x+1 80 | %endrep 81 | 82 | const sw_64, dd 64 83 | -------------------------------------------------------------------------------- /encode_test.go: -------------------------------------------------------------------------------- 1 | package x264 2 | 3 | import ( 4 | "bytes" 5 | "image" 6 | "image/color" 7 | "image/draw" 8 | "os" 9 | "path/filepath" 10 | "testing" 11 | ) 12 | 13 | func TestEncode(t *testing.T) { 14 | buf := bytes.NewBuffer(make([]byte, 0)) 15 | 16 | opts := &Options{ 17 | Width: 640, 18 | Height: 480, 19 | FrameRate: 25, 20 | Tune: "zerolatency", 21 | Preset: "veryfast", 22 | Profile: "baseline", 23 | LogLevel: LogDebug, 24 | } 25 | 26 | enc, err := NewEncoder(buf, opts) 27 | if err != nil { 28 | t.Fatal(err) 29 | } 30 | 31 | img := NewYCbCr(image.Rect(0, 0, opts.Width, opts.Height)) 32 | draw.Draw(img, img.Bounds(), image.Black, image.ZP, draw.Src) 33 | 34 | for i := 0; i < opts.Width/2; i++ { 35 | img.Set(i, opts.Height/2, color.RGBA{R: 255, A: 255}) 36 | 37 | err = enc.Encode(img) 38 | if err != nil { 39 | t.Error(err) 40 | } 41 | } 42 | 43 | err = enc.Flush() 44 | if err != nil { 45 | t.Error(err) 46 | } 47 | 48 | err = enc.Close() 49 | if err != nil { 50 | t.Error(err) 51 | } 52 | 53 | err = os.WriteFile(filepath.Join(os.TempDir(), "test.264"), buf.Bytes(), 0644) 54 | if err != nil { 55 | t.Error(err) 56 | } 57 | } 58 | 59 | func TestEncodeFlush(t *testing.T) { 60 | buf := bytes.NewBuffer(make([]byte, 0)) 61 | 62 | opts := &Options{ 63 | Width: 640, 64 | Height: 480, 65 | FrameRate: 25, 66 | Tune: "film", 67 | Preset: "fast", 68 | Profile: "high", 69 | LogLevel: LogDebug, 70 | } 71 | 72 | enc, err := NewEncoder(buf, opts) 73 | if err != nil { 74 | t.Fatal(err) 75 | } 76 | 77 | img := NewYCbCr(image.Rect(0, 0, opts.Width, opts.Height)) 78 | draw.Draw(img, img.Bounds(), image.Black, image.ZP, draw.Src) 79 | 80 | for i := 0; i < opts.Width/2; i++ { 81 | img.Set(i, opts.Height/2, color.RGBA{R: 255, A: 255}) 82 | 83 | err = enc.Encode(img) 84 | if err != nil { 85 | t.Error(err) 86 | } 87 | } 88 | 89 | err = enc.Flush() 90 | if err != nil { 91 | t.Error(err) 92 | } 93 | 94 | err = enc.Close() 95 | if err != nil { 96 | t.Error(err) 97 | } 98 | 99 | err = os.WriteFile(filepath.Join(os.TempDir(), "test.high.264"), buf.Bytes(), 0644) 100 | if err != nil { 101 | t.Error(err) 102 | } 103 | } 104 | 105 | func TestEncodeCrf(t *testing.T) { 106 | buf := bytes.NewBuffer(make([]byte, 0)) 107 | 108 | opts := &Options{ 109 | Width: 640, 110 | Height: 480, 111 | FrameRate: 25, 112 | Tune: "zerolatency", 113 | Preset: "veryfast", 114 | Profile: "baseline", 115 | RateControl: "crf", 116 | RateConstant: 18, 117 | LogLevel: LogDebug, 118 | } 119 | 120 | enc, err := NewEncoder(buf, opts) 121 | if err != nil { 122 | t.Fatal(err) 123 | } 124 | 125 | img := NewYCbCr(image.Rect(0, 0, opts.Width, opts.Height)) 126 | draw.Draw(img, img.Bounds(), image.Black, image.ZP, draw.Src) 127 | 128 | for i := 0; i < opts.Width/2; i++ { 129 | img.Set(i, opts.Height/2, color.RGBA{R: 255, A: 255}) 130 | 131 | err = enc.Encode(img) 132 | if err != nil { 133 | t.Error(err) 134 | } 135 | } 136 | 137 | err = enc.Flush() 138 | if err != nil { 139 | t.Error(err) 140 | } 141 | 142 | err = enc.Close() 143 | if err != nil { 144 | t.Error(err) 145 | } 146 | 147 | err = os.WriteFile(filepath.Join(os.TempDir(), "test.crf.264"), buf.Bytes(), 0644) 148 | if err != nil { 149 | t.Error(err) 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /yuv/yuv.go: -------------------------------------------------------------------------------- 1 | package yuv 2 | 3 | import ( 4 | "image" 5 | "runtime" 6 | "sync" 7 | "unsafe" 8 | ) 9 | 10 | /* 11 | #cgo CFLAGS: -Wall -O3 12 | #include "yuv.h" 13 | */ 14 | import "C" 15 | 16 | type ImgProcessor interface { 17 | Process(rgba *image.RGBA) ImgProcessor 18 | Get() []byte 19 | } 20 | 21 | type processor struct { 22 | Data []byte 23 | w, h int 24 | pos ChromaPos 25 | 26 | // cache 27 | dst unsafe.Pointer 28 | ww C.int 29 | chroma C.chromaPos 30 | } 31 | 32 | type threadedProcessor struct { 33 | *processor 34 | 35 | // threading 36 | threads int 37 | chunk int 38 | 39 | // cache 40 | chromaU C.int 41 | chromaV C.int 42 | } 43 | 44 | type ChromaPos uint8 45 | 46 | const ( 47 | TopLeft ChromaPos = iota 48 | BetweenFour 49 | ) 50 | 51 | // NewYuvImgProcessor creates new YUV image converter from RGBA. 52 | func NewYuvImgProcessor(w, h int, options ...Option) ImgProcessor { 53 | opts := &Options{ 54 | ChromaP: BetweenFour, 55 | Threaded: true, 56 | Threads: runtime.NumCPU(), 57 | } 58 | opts.override(options...) 59 | 60 | bufSize := int(float32(w*h) * 1.5) 61 | buf := make([]byte, bufSize) 62 | 63 | processor := processor{ 64 | Data: buf, 65 | chroma: C.chromaPos(opts.ChromaP), 66 | dst: unsafe.Pointer(&buf[0]), 67 | h: h, 68 | pos: opts.ChromaP, 69 | w: w, 70 | ww: C.int(w), 71 | } 72 | 73 | if opts.Threaded { 74 | // chunks the image evenly 75 | chunk := h / opts.Threads 76 | if chunk%2 != 0 { 77 | chunk-- 78 | } 79 | 80 | return &threadedProcessor{ 81 | chromaU: C.int(w * h), 82 | chromaV: C.int(w*h + w*h/4), 83 | chunk: chunk, 84 | processor: &processor, 85 | threads: opts.Threads, 86 | } 87 | } 88 | return &processor 89 | } 90 | 91 | func (yuv *processor) Get() []byte { 92 | return yuv.Data 93 | } 94 | 95 | // Process converts RGBA colorspace into YUV I420 format inside the internal buffer. 96 | // Non-threaded version. 97 | func (yuv *processor) Process(rgba *image.RGBA) ImgProcessor { 98 | C.rgbaToYuv(yuv.dst, unsafe.Pointer(&rgba.Pix[0]), yuv.ww, C.int(yuv.h), yuv.chroma) 99 | return yuv 100 | } 101 | 102 | func (yuv *threadedProcessor) Get() []byte { 103 | return yuv.Data 104 | } 105 | 106 | // Process converts RGBA colorspace into YUV I420 format inside the internal buffer. 107 | // Threaded version. 108 | // 109 | // We divide the input image into chunks by the number of available CPUs. 110 | // Each chunk should contain 2, 4, 6, and etc. rows of the image. 111 | // 112 | // 8x4 CPU (2) 113 | // x x x x x x x x | Coroutine 1 114 | // x x x x x x x x | Coroutine 1 115 | // x x x x x x x x | Coroutine 2 116 | // x x x x x x x x | Coroutine 2 117 | // 118 | func (yuv *threadedProcessor) Process(rgba *image.RGBA) ImgProcessor { 119 | src := unsafe.Pointer(&rgba.Pix[0]) 120 | wg := sync.WaitGroup{} 121 | wg.Add(2 * yuv.threads) 122 | for i := 0; i < yuv.threads; i++ { 123 | pos, hh := C.int(yuv.w*i*yuv.chunk), C.int(yuv.chunk) 124 | // we need to know how many pixels left 125 | // if the image can't be divided evenly 126 | // between all the threads 127 | if i == yuv.threads-1 { 128 | hh = C.int(yuv.h - i*yuv.chunk) 129 | } 130 | go func() { defer wg.Done(); C.luma(yuv.dst, src, pos, yuv.ww, hh) }() 131 | go func() { 132 | defer wg.Done() 133 | C.chroma(yuv.dst, src, pos, yuv.chromaU, yuv.chromaV, yuv.ww, hh, yuv.chroma) 134 | }() 135 | } 136 | wg.Wait() 137 | return yuv 138 | } 139 | -------------------------------------------------------------------------------- /x264c/external/x264/common/dct.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * dct.h: transform and zigzag 3 | ***************************************************************************** 4 | * Copyright (C) 2004-2022 x264 project 5 | * 6 | * Authors: Loren Merritt 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_DCT_H 27 | #define X264_DCT_H 28 | 29 | typedef struct 30 | { 31 | // pix1 stride = FENC_STRIDE 32 | // pix2 stride = FDEC_STRIDE 33 | // p_dst stride = FDEC_STRIDE 34 | void (*sub4x4_dct) ( dctcoef dct[16], pixel *pix1, pixel *pix2 ); 35 | void (*add4x4_idct)( pixel *p_dst, dctcoef dct[16] ); 36 | 37 | void (*sub8x8_dct) ( dctcoef dct[4][16], pixel *pix1, pixel *pix2 ); 38 | void (*sub8x8_dct_dc) ( dctcoef dct[4], pixel *pix1, pixel *pix2 ); 39 | void (*add8x8_idct) ( pixel *p_dst, dctcoef dct[4][16] ); 40 | void (*add8x8_idct_dc)( pixel *p_dst, dctcoef dct[4] ); 41 | 42 | void (*sub8x16_dct_dc)( dctcoef dct[8], pixel *pix1, pixel *pix2 ); 43 | 44 | void (*sub16x16_dct) ( dctcoef dct[16][16], pixel *pix1, pixel *pix2 ); 45 | void (*add16x16_idct) ( pixel *p_dst, dctcoef dct[16][16] ); 46 | void (*add16x16_idct_dc)( pixel *p_dst, dctcoef dct[16] ); 47 | 48 | void (*sub8x8_dct8) ( dctcoef dct[64], pixel *pix1, pixel *pix2 ); 49 | void (*add8x8_idct8)( pixel *p_dst, dctcoef dct[64] ); 50 | 51 | void (*sub16x16_dct8) ( dctcoef dct[4][64], pixel *pix1, pixel *pix2 ); 52 | void (*add16x16_idct8)( pixel *p_dst, dctcoef dct[4][64] ); 53 | 54 | void (*dct4x4dc) ( dctcoef d[16] ); 55 | void (*idct4x4dc)( dctcoef d[16] ); 56 | 57 | void (*dct2x4dc)( dctcoef dct[8], dctcoef dct4x4[8][16] ); 58 | 59 | } x264_dct_function_t; 60 | 61 | typedef struct 62 | { 63 | void (*scan_8x8)( dctcoef level[64], dctcoef dct[64] ); 64 | void (*scan_4x4)( dctcoef level[16], dctcoef dct[16] ); 65 | int (*sub_8x8) ( dctcoef level[64], const pixel *p_src, pixel *p_dst ); 66 | int (*sub_4x4) ( dctcoef level[16], const pixel *p_src, pixel *p_dst ); 67 | int (*sub_4x4ac)( dctcoef level[16], const pixel *p_src, pixel *p_dst, dctcoef *dc ); 68 | void (*interleave_8x8_cavlc)( dctcoef *dst, dctcoef *src, uint8_t *nnz ); 69 | 70 | } x264_zigzag_function_t; 71 | 72 | #define x264_dct_init x264_template(dct_init) 73 | void x264_dct_init( uint32_t cpu, x264_dct_function_t *dctf ); 74 | #define x264_zigzag_init x264_template(zigzag_init) 75 | void x264_zigzag_init( uint32_t cpu, x264_zigzag_function_t *pf_progressive, x264_zigzag_function_t *pf_interlaced ); 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /x264c/external/x264/common/mips/dct.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * dct.h: msa transform and zigzag 3 | ***************************************************************************** 4 | * Copyright (C) 2015-2022 x264 project 5 | * 6 | * Authors: Rishikesh More 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_MIPS_DCT_H 27 | #define X264_MIPS_DCT_H 28 | 29 | #define x264_dct4x4dc_msa x264_template(dct4x4dc_msa) 30 | void x264_dct4x4dc_msa( int16_t d[16] ); 31 | #define x264_idct4x4dc_msa x264_template(idct4x4dc_msa) 32 | void x264_idct4x4dc_msa( int16_t d[16] ); 33 | #define x264_add4x4_idct_msa x264_template(add4x4_idct_msa) 34 | void x264_add4x4_idct_msa( uint8_t *p_dst, int16_t pi_dct[16] ); 35 | #define x264_add8x8_idct_msa x264_template(add8x8_idct_msa) 36 | void x264_add8x8_idct_msa( uint8_t *p_dst, int16_t pi_dct[4][16] ); 37 | #define x264_add16x16_idct_msa x264_template(add16x16_idct_msa) 38 | void x264_add16x16_idct_msa( uint8_t *p_dst, int16_t pi_dct[16][16] ); 39 | #define x264_add8x8_idct8_msa x264_template(add8x8_idct8_msa) 40 | void x264_add8x8_idct8_msa( uint8_t *p_dst, int16_t pi_dct[64] ); 41 | #define x264_add16x16_idct8_msa x264_template(add16x16_idct8_msa) 42 | void x264_add16x16_idct8_msa( uint8_t *p_dst, int16_t pi_dct[4][64] ); 43 | #define x264_add8x8_idct_dc_msa x264_template(add8x8_idct_dc_msa) 44 | void x264_add8x8_idct_dc_msa( uint8_t *p_dst, int16_t pi_dct[4] ); 45 | #define x264_add16x16_idct_dc_msa x264_template(add16x16_idct_dc_msa) 46 | void x264_add16x16_idct_dc_msa( uint8_t *p_dst, int16_t pi_dct[16] ); 47 | #define x264_sub4x4_dct_msa x264_template(sub4x4_dct_msa) 48 | void x264_sub4x4_dct_msa( int16_t p_dst[16], uint8_t *p_src, uint8_t *p_ref ); 49 | #define x264_sub8x8_dct_msa x264_template(sub8x8_dct_msa) 50 | void x264_sub8x8_dct_msa( int16_t p_dst[4][16], uint8_t *p_src, 51 | uint8_t *p_ref ); 52 | #define x264_sub16x16_dct_msa x264_template(sub16x16_dct_msa) 53 | void x264_sub16x16_dct_msa( int16_t p_dst[16][16], uint8_t *p_src, 54 | uint8_t *p_ref ); 55 | #define x264_sub8x8_dct_dc_msa x264_template(sub8x8_dct_dc_msa) 56 | void x264_sub8x8_dct_dc_msa( int16_t pi_dct[4], uint8_t *p_pix1, 57 | uint8_t *p_pix2 ); 58 | #define x264_sub8x16_dct_dc_msa x264_template(sub8x16_dct_dc_msa) 59 | void x264_sub8x16_dct_dc_msa( int16_t pi_dct[8], uint8_t *p_pix1, 60 | uint8_t *p_pix2 ); 61 | #define x264_zigzag_scan_4x4_frame_msa x264_template(zigzag_scan_4x4_frame_msa) 62 | void x264_zigzag_scan_4x4_frame_msa( int16_t pi_level[16], int16_t pi_dct[16] ); 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /x264c/external/x264/common/x86/cpu-a.asm: -------------------------------------------------------------------------------- 1 | ;***************************************************************************** 2 | ;* cpu-a.asm: x86 cpu utilities 3 | ;***************************************************************************** 4 | ;* Copyright (C) 2003-2022 x264 project 5 | ;* 6 | ;* Authors: Laurent Aimar 7 | ;* Loren Merritt 8 | ;* Fiona Glaser 9 | ;* 10 | ;* This program is free software; you can redistribute it and/or modify 11 | ;* it under the terms of the GNU General Public License as published by 12 | ;* the Free Software Foundation; either version 2 of the License, or 13 | ;* (at your option) any later version. 14 | ;* 15 | ;* This program is distributed in the hope that it will be useful, 16 | ;* but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | ;* GNU General Public License for more details. 19 | ;* 20 | ;* You should have received a copy of the GNU General Public License 21 | ;* along with this program; if not, write to the Free Software 22 | ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 23 | ;* 24 | ;* This program is also available under a commercial proprietary license. 25 | ;* For more information, contact us at licensing@x264.com. 26 | ;***************************************************************************** 27 | 28 | %include "x86inc.asm" 29 | 30 | SECTION .text 31 | 32 | ;----------------------------------------------------------------------------- 33 | ; void cpu_cpuid( int op, int *eax, int *ebx, int *ecx, int *edx ) 34 | ;----------------------------------------------------------------------------- 35 | cglobal cpu_cpuid, 5,7 36 | push rbx 37 | push r4 38 | push r3 39 | push r2 40 | push r1 41 | mov eax, r0d 42 | xor ecx, ecx 43 | cpuid 44 | pop r4 45 | mov [r4], eax 46 | pop r4 47 | mov [r4], ebx 48 | pop r4 49 | mov [r4], ecx 50 | pop r4 51 | mov [r4], edx 52 | pop rbx 53 | RET 54 | 55 | ;----------------------------------------------------------------------------- 56 | ; uint64_t cpu_xgetbv( int xcr ) 57 | ;----------------------------------------------------------------------------- 58 | cglobal cpu_xgetbv 59 | movifnidn ecx, r0m 60 | xgetbv 61 | %if ARCH_X86_64 62 | shl rdx, 32 63 | or rax, rdx 64 | %endif 65 | ret 66 | 67 | ;----------------------------------------------------------------------------- 68 | ; void cpu_emms( void ) 69 | ;----------------------------------------------------------------------------- 70 | cglobal cpu_emms 71 | emms 72 | ret 73 | 74 | ;----------------------------------------------------------------------------- 75 | ; void cpu_sfence( void ) 76 | ;----------------------------------------------------------------------------- 77 | cglobal cpu_sfence 78 | sfence 79 | ret 80 | 81 | %if ARCH_X86_64 == 0 82 | ;----------------------------------------------------------------------------- 83 | ; int cpu_cpuid_test( void ) 84 | ; return 0 if unsupported 85 | ;----------------------------------------------------------------------------- 86 | cglobal cpu_cpuid_test 87 | pushfd 88 | push ebx 89 | push ebp 90 | push esi 91 | push edi 92 | pushfd 93 | pop eax 94 | mov ebx, eax 95 | xor eax, 0x200000 96 | push eax 97 | popfd 98 | pushfd 99 | pop eax 100 | xor eax, ebx 101 | pop edi 102 | pop esi 103 | pop ebp 104 | pop ebx 105 | popfd 106 | ret 107 | %endif 108 | -------------------------------------------------------------------------------- /x264c/external/x264/common/arm/quant.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * quant.h: arm quantization and level-run 3 | ***************************************************************************** 4 | * Copyright (C) 2005-2022 x264 project 5 | * 6 | * Authors: David Conrad 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_ARM_QUANT_H 27 | #define X264_ARM_QUANT_H 28 | 29 | #define x264_quant_2x2_dc_armv6 x264_template(quant_2x2_dc_armv6) 30 | int x264_quant_2x2_dc_armv6( int16_t dct[4], int mf, int bias ); 31 | 32 | #define x264_quant_2x2_dc_neon x264_template(quant_2x2_dc_neon) 33 | int x264_quant_2x2_dc_neon( int16_t dct[4], int mf, int bias ); 34 | #define x264_quant_4x4_dc_neon x264_template(quant_4x4_dc_neon) 35 | int x264_quant_4x4_dc_neon( int16_t dct[16], int mf, int bias ); 36 | #define x264_quant_4x4_neon x264_template(quant_4x4_neon) 37 | int x264_quant_4x4_neon( int16_t dct[16], uint16_t mf[16], uint16_t bias[16] ); 38 | #define x264_quant_4x4x4_neon x264_template(quant_4x4x4_neon) 39 | int x264_quant_4x4x4_neon( int16_t dct[4][16], uint16_t mf[16], uint16_t bias[16] ); 40 | #define x264_quant_8x8_neon x264_template(quant_8x8_neon) 41 | int x264_quant_8x8_neon( int16_t dct[64], uint16_t mf[64], uint16_t bias[64] ); 42 | 43 | #define x264_dequant_4x4_dc_neon x264_template(dequant_4x4_dc_neon) 44 | void x264_dequant_4x4_dc_neon( int16_t dct[16], int dequant_mf[6][16], int i_qp ); 45 | #define x264_dequant_4x4_neon x264_template(dequant_4x4_neon) 46 | void x264_dequant_4x4_neon( int16_t dct[16], int dequant_mf[6][16], int i_qp ); 47 | #define x264_dequant_8x8_neon x264_template(dequant_8x8_neon) 48 | void x264_dequant_8x8_neon( int16_t dct[64], int dequant_mf[6][64], int i_qp ); 49 | 50 | #define x264_decimate_score15_neon x264_template(decimate_score15_neon) 51 | int x264_decimate_score15_neon( int16_t * ); 52 | #define x264_decimate_score16_neon x264_template(decimate_score16_neon) 53 | int x264_decimate_score16_neon( int16_t * ); 54 | #define x264_decimate_score64_neon x264_template(decimate_score64_neon) 55 | int x264_decimate_score64_neon( int16_t * ); 56 | 57 | #define x264_coeff_last4_arm x264_template(coeff_last4_arm) 58 | int x264_coeff_last4_arm( int16_t * ); 59 | #define x264_coeff_last8_arm x264_template(coeff_last8_arm) 60 | int x264_coeff_last8_arm( int16_t * ); 61 | #define x264_coeff_last15_neon x264_template(coeff_last15_neon) 62 | int x264_coeff_last15_neon( int16_t * ); 63 | #define x264_coeff_last16_neon x264_template(coeff_last16_neon) 64 | int x264_coeff_last16_neon( int16_t * ); 65 | #define x264_coeff_last64_neon x264_template(coeff_last64_neon) 66 | int x264_coeff_last64_neon( int16_t * ); 67 | 68 | #define x264_denoise_dct_neon x264_template(denoise_dct_neon) 69 | void x264_denoise_dct_neon( dctcoef *, uint32_t *, udctcoef *, int ); 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /x264c/external/x264/common/osdep.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * osdep.c: platform-specific code 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2022 x264 project 5 | * 6 | * Authors: Steven Walters 7 | * Laurent Aimar 8 | * Henrik Gramner 9 | * 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program; if not, write to the Free Software 22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 23 | * 24 | * This program is also available under a commercial proprietary license. 25 | * For more information, contact us at licensing@x264.com. 26 | *****************************************************************************/ 27 | 28 | #include "osdep.h" 29 | 30 | #if SYS_WINDOWS 31 | #include 32 | #include 33 | #else 34 | #include 35 | #endif 36 | #include 37 | 38 | #if PTW32_STATIC_LIB 39 | /* this is a global in pthread-win32 to indicate if it has been initialized or not */ 40 | extern int ptw32_processInitialized; 41 | #endif 42 | 43 | int64_t x264_mdate( void ) 44 | { 45 | #if SYS_WINDOWS 46 | struct timeb tb; 47 | ftime( &tb ); 48 | return ((int64_t)tb.time * 1000 + (int64_t)tb.millitm) * 1000; 49 | #elif HAVE_CLOCK_GETTIME 50 | struct timespec ts; 51 | clock_gettime( CLOCK_MONOTONIC, &ts ); 52 | return (int64_t)ts.tv_sec * 1000000 + (int64_t)ts.tv_nsec / 1000; 53 | #else 54 | struct timeval tv_date; 55 | gettimeofday( &tv_date, NULL ); 56 | return (int64_t)tv_date.tv_sec * 1000000 + (int64_t)tv_date.tv_usec; 57 | #endif 58 | } 59 | 60 | #if HAVE_WIN32THREAD || PTW32_STATIC_LIB 61 | /* state of the threading library being initialized */ 62 | static volatile LONG threading_is_init = 0; 63 | 64 | static void threading_destroy( void ) 65 | { 66 | #if PTW32_STATIC_LIB 67 | pthread_win32_thread_detach_np(); 68 | pthread_win32_process_detach_np(); 69 | #else 70 | x264_win32_threading_destroy(); 71 | #endif 72 | } 73 | 74 | static int threading_init( void ) 75 | { 76 | #if PTW32_STATIC_LIB 77 | /* if static pthread-win32 is already initialized, then do nothing */ 78 | if( ptw32_processInitialized ) 79 | return 0; 80 | if( !pthread_win32_process_attach_np() ) 81 | return -1; 82 | #else 83 | if( x264_win32_threading_init() ) 84 | return -1; 85 | #endif 86 | /* register cleanup to run at process termination */ 87 | atexit( threading_destroy ); 88 | return 0; 89 | } 90 | 91 | int x264_threading_init( void ) 92 | { 93 | LONG state; 94 | while( (state = InterlockedCompareExchange( &threading_is_init, -1, 0 )) != 0 ) 95 | { 96 | /* if already init, then do nothing */ 97 | if( state > 0 ) 98 | return 0; 99 | } 100 | if( threading_init() < 0 ) 101 | { 102 | InterlockedExchange( &threading_is_init, 0 ); 103 | return -1; 104 | } 105 | InterlockedExchange( &threading_is_init, 1 ); 106 | return 0; 107 | } 108 | #endif 109 | -------------------------------------------------------------------------------- /x264c/external/x264/common/arm/dct.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * dct.h: arm transform and zigzag 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2022 x264 project 5 | * 6 | * Authors: David Conrad 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_ARM_DCT_H 27 | #define X264_ARM_DCT_H 28 | 29 | #define x264_dct4x4dc_neon x264_template(dct4x4dc_neon) 30 | void x264_dct4x4dc_neon( int16_t d[16] ); 31 | #define x264_idct4x4dc_neon x264_template(idct4x4dc_neon) 32 | void x264_idct4x4dc_neon( int16_t d[16] ); 33 | 34 | #define x264_sub4x4_dct_neon x264_template(sub4x4_dct_neon) 35 | void x264_sub4x4_dct_neon( int16_t dct[16], uint8_t *pix1, uint8_t *pix2 ); 36 | #define x264_sub8x8_dct_neon x264_template(sub8x8_dct_neon) 37 | void x264_sub8x8_dct_neon( int16_t dct[4][16], uint8_t *pix1, uint8_t *pix2 ); 38 | #define x264_sub16x16_dct_neon x264_template(sub16x16_dct_neon) 39 | void x264_sub16x16_dct_neon( int16_t dct[16][16], uint8_t *pix1, uint8_t *pix2 ); 40 | 41 | #define x264_add4x4_idct_neon x264_template(add4x4_idct_neon) 42 | void x264_add4x4_idct_neon( uint8_t *p_dst, int16_t dct[16] ); 43 | #define x264_add8x8_idct_neon x264_template(add8x8_idct_neon) 44 | void x264_add8x8_idct_neon( uint8_t *p_dst, int16_t dct[4][16] ); 45 | #define x264_add16x16_idct_neon x264_template(add16x16_idct_neon) 46 | void x264_add16x16_idct_neon( uint8_t *p_dst, int16_t dct[16][16] ); 47 | 48 | #define x264_add8x8_idct_dc_neon x264_template(add8x8_idct_dc_neon) 49 | void x264_add8x8_idct_dc_neon( uint8_t *p_dst, int16_t dct[4] ); 50 | #define x264_add16x16_idct_dc_neon x264_template(add16x16_idct_dc_neon) 51 | void x264_add16x16_idct_dc_neon( uint8_t *p_dst, int16_t dct[16] ); 52 | #define x264_sub8x8_dct_dc_neon x264_template(sub8x8_dct_dc_neon) 53 | void x264_sub8x8_dct_dc_neon( int16_t dct[4], uint8_t *pix1, uint8_t *pix2 ); 54 | #define x264_sub8x16_dct_dc_neon x264_template(sub8x16_dct_dc_neon) 55 | void x264_sub8x16_dct_dc_neon( int16_t dct[8], uint8_t *pix1, uint8_t *pix2 ); 56 | 57 | #define x264_sub8x8_dct8_neon x264_template(sub8x8_dct8_neon) 58 | void x264_sub8x8_dct8_neon( int16_t dct[64], uint8_t *pix1, uint8_t *pix2 ); 59 | #define x264_sub16x16_dct8_neon x264_template(sub16x16_dct8_neon) 60 | void x264_sub16x16_dct8_neon( int16_t dct[4][64], uint8_t *pix1, uint8_t *pix2 ); 61 | 62 | #define x264_add8x8_idct8_neon x264_template(add8x8_idct8_neon) 63 | void x264_add8x8_idct8_neon( uint8_t *p_dst, int16_t dct[64] ); 64 | #define x264_add16x16_idct8_neon x264_template(add16x16_idct8_neon) 65 | void x264_add16x16_idct8_neon( uint8_t *p_dst, int16_t dct[4][64] ); 66 | 67 | #define x264_zigzag_scan_4x4_frame_neon x264_template(zigzag_scan_4x4_frame_neon) 68 | void x264_zigzag_scan_4x4_frame_neon( int16_t level[16], int16_t dct[16] ); 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /x264c/external/x264/common/arm/deblock.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * deblock.h: arm deblocking 3 | ***************************************************************************** 4 | * Copyright (C) 2017-2022 x264 project 5 | * 6 | * Authors: Anton Mitrofanov 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_ARM_DEBLOCK_H 27 | #define X264_ARM_DEBLOCK_H 28 | 29 | #define x264_deblock_v_luma_neon x264_template(deblock_v_luma_neon) 30 | void x264_deblock_v_luma_neon ( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 31 | #define x264_deblock_h_luma_neon x264_template(deblock_h_luma_neon) 32 | void x264_deblock_h_luma_neon ( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 33 | #define x264_deblock_v_chroma_neon x264_template(deblock_v_chroma_neon) 34 | void x264_deblock_v_chroma_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 35 | #define x264_deblock_h_chroma_neon x264_template(deblock_h_chroma_neon) 36 | void x264_deblock_h_chroma_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 37 | #define x264_deblock_strength_neon x264_template(deblock_strength_neon) 38 | void x264_deblock_strength_neon( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE], 39 | int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][8][4], 40 | int mvy_limit, int bframe ); 41 | #define x264_deblock_h_chroma_422_neon x264_template(deblock_h_chroma_422_neon) 42 | void x264_deblock_h_chroma_422_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 43 | #define x264_deblock_h_chroma_mbaff_neon x264_template(deblock_h_chroma_mbaff_neon) 44 | void x264_deblock_h_chroma_mbaff_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 45 | #define x264_deblock_h_chroma_intra_mbaff_neon x264_template(deblock_h_chroma_intra_mbaff_neon) 46 | void x264_deblock_h_chroma_intra_mbaff_neon( uint8_t *pix, intptr_t stride, int alpha, int beta ); 47 | #define x264_deblock_h_chroma_intra_neon x264_template(deblock_h_chroma_intra_neon) 48 | void x264_deblock_h_chroma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta ); 49 | #define x264_deblock_h_chroma_422_intra_neon x264_template(deblock_h_chroma_422_intra_neon) 50 | void x264_deblock_h_chroma_422_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta ); 51 | #define x264_deblock_v_chroma_intra_neon x264_template(deblock_v_chroma_intra_neon) 52 | void x264_deblock_v_chroma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta ); 53 | #define x264_deblock_h_luma_intra_neon x264_template(deblock_h_luma_intra_neon) 54 | void x264_deblock_h_luma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta ); 55 | #define x264_deblock_v_luma_intra_neon x264_template(deblock_v_luma_intra_neon) 56 | void x264_deblock_v_luma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta ); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /x264c/external/x264/common/aarch64/deblock.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * deblock.h: aarch64 deblocking 3 | ***************************************************************************** 4 | * Copyright (C) 2017-2022 x264 project 5 | * 6 | * Authors: Anton Mitrofanov 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_AARCH64_DEBLOCK_H 27 | #define X264_AARCH64_DEBLOCK_H 28 | 29 | #define x264_deblock_v_luma_neon x264_template(deblock_v_luma_neon) 30 | void x264_deblock_v_luma_neon ( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 31 | #define x264_deblock_h_luma_neon x264_template(deblock_h_luma_neon) 32 | void x264_deblock_h_luma_neon ( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 33 | #define x264_deblock_v_chroma_neon x264_template(deblock_v_chroma_neon) 34 | void x264_deblock_v_chroma_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 35 | #define x264_deblock_h_chroma_neon x264_template(deblock_h_chroma_neon) 36 | void x264_deblock_h_chroma_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 37 | #define x264_deblock_strength_neon x264_template(deblock_strength_neon) 38 | void x264_deblock_strength_neon( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE], 39 | int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][8][4], 40 | int mvy_limit, int bframe ); 41 | #define x264_deblock_h_chroma_422_neon x264_template(deblock_h_chroma_422_neon) 42 | void x264_deblock_h_chroma_422_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 43 | #define x264_deblock_h_chroma_mbaff_neon x264_template(deblock_h_chroma_mbaff_neon) 44 | void x264_deblock_h_chroma_mbaff_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ); 45 | #define x264_deblock_h_chroma_intra_mbaff_neon x264_template(deblock_h_chroma_intra_mbaff_neon) 46 | void x264_deblock_h_chroma_intra_mbaff_neon( uint8_t *pix, intptr_t stride, int alpha, int beta ); 47 | #define x264_deblock_h_chroma_intra_neon x264_template(deblock_h_chroma_intra_neon) 48 | void x264_deblock_h_chroma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta ); 49 | #define x264_deblock_h_chroma_422_intra_neon x264_template(deblock_h_chroma_422_intra_neon) 50 | void x264_deblock_h_chroma_422_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta ); 51 | #define x264_deblock_v_chroma_intra_neon x264_template(deblock_v_chroma_intra_neon) 52 | void x264_deblock_v_chroma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta ); 53 | #define x264_deblock_h_luma_intra_neon x264_template(deblock_h_luma_intra_neon) 54 | void x264_deblock_h_luma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta ); 55 | #define x264_deblock_v_luma_intra_neon x264_template(deblock_v_luma_intra_neon) 56 | void x264_deblock_v_luma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta ); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /x264c/external/x264/common/quant.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * quant.h: quantization and level-run 3 | ***************************************************************************** 4 | * Copyright (C) 2005-2022 x264 project 5 | * 6 | * Authors: Loren Merritt 7 | * Fiona Glaser 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 22 | * 23 | * This program is also available under a commercial proprietary license. 24 | * For more information, contact us at licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #ifndef X264_QUANT_H 28 | #define X264_QUANT_H 29 | 30 | typedef struct 31 | { 32 | int (*quant_8x8) ( dctcoef dct[64], udctcoef mf[64], udctcoef bias[64] ); 33 | int (*quant_4x4) ( dctcoef dct[16], udctcoef mf[16], udctcoef bias[16] ); 34 | int (*quant_4x4x4)( dctcoef dct[4][16], udctcoef mf[16], udctcoef bias[16] ); 35 | int (*quant_4x4_dc)( dctcoef dct[16], int mf, int bias ); 36 | int (*quant_2x2_dc)( dctcoef dct[4], int mf, int bias ); 37 | 38 | void (*dequant_8x8)( dctcoef dct[64], int dequant_mf[6][64], int i_qp ); 39 | void (*dequant_4x4)( dctcoef dct[16], int dequant_mf[6][16], int i_qp ); 40 | void (*dequant_4x4_dc)( dctcoef dct[16], int dequant_mf[6][16], int i_qp ); 41 | 42 | void (*idct_dequant_2x4_dc)( dctcoef dct[8], dctcoef dct4x4[8][16], int dequant_mf[6][16], int i_qp ); 43 | void (*idct_dequant_2x4_dconly)( dctcoef dct[8], int dequant_mf[6][16], int i_qp ); 44 | 45 | int (*optimize_chroma_2x2_dc)( dctcoef dct[4], int dequant_mf ); 46 | int (*optimize_chroma_2x4_dc)( dctcoef dct[8], int dequant_mf ); 47 | 48 | void (*denoise_dct)( dctcoef *dct, uint32_t *sum, udctcoef *offset, int size ); 49 | 50 | int (*decimate_score15)( dctcoef *dct ); 51 | int (*decimate_score16)( dctcoef *dct ); 52 | int (*decimate_score64)( dctcoef *dct ); 53 | int (*coeff_last[14])( dctcoef *dct ); 54 | int (*coeff_last4)( dctcoef *dct ); 55 | int (*coeff_last8)( dctcoef *dct ); 56 | int (*coeff_level_run[13])( dctcoef *dct, x264_run_level_t *runlevel ); 57 | int (*coeff_level_run4)( dctcoef *dct, x264_run_level_t *runlevel ); 58 | int (*coeff_level_run8)( dctcoef *dct, x264_run_level_t *runlevel ); 59 | 60 | #define TRELLIS_PARAMS const int *unquant_mf, const uint8_t *zigzag, int lambda2,\ 61 | int last_nnz, dctcoef *coefs, dctcoef *quant_coefs, dctcoef *dct,\ 62 | uint8_t *cabac_state_sig, uint8_t *cabac_state_last,\ 63 | uint64_t level_state0, uint16_t level_state1 64 | int (*trellis_cabac_4x4)( TRELLIS_PARAMS, int b_ac ); 65 | int (*trellis_cabac_8x8)( TRELLIS_PARAMS, int b_interlaced ); 66 | int (*trellis_cabac_4x4_psy)( TRELLIS_PARAMS, int b_ac, dctcoef *fenc_dct, int psy_trellis ); 67 | int (*trellis_cabac_8x8_psy)( TRELLIS_PARAMS, int b_interlaced, dctcoef *fenc_dct, int psy_trellis ); 68 | int (*trellis_cabac_dc)( TRELLIS_PARAMS, int num_coefs ); 69 | int (*trellis_cabac_chroma_422_dc)( TRELLIS_PARAMS ); 70 | } x264_quant_function_t; 71 | 72 | #define x264_quant_init x264_template(quant_init) 73 | void x264_quant_init( x264_t *h, uint32_t cpu, x264_quant_function_t *pf ); 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /x264c/external/x264/common/arm/cpu-a.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * cpu-a.S: arm cpu detection 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2022 x264 project 5 | * 6 | * Authors: David Conrad 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #include "asm.S" 27 | 28 | .align 2 29 | 30 | // done in gas because .fpu neon overrides the refusal to assemble 31 | // instructions the selected -march/-mcpu doesn't support 32 | function cpu_neon_test 33 | vadd.i16 q0, q0, q0 34 | bx lr 35 | endfunc 36 | 37 | // return: 0 on success 38 | // 1 if counters were already enabled 39 | // 9 if lo-res counters were already enabled 40 | function cpu_enable_armv7_counter, export=0 41 | mrc p15, 0, r2, c9, c12, 0 // read PMNC 42 | ands r0, r2, #1 43 | andne r0, r2, #9 44 | 45 | orr r2, r2, #1 // enable counters 46 | bic r2, r2, #8 // full resolution 47 | mcreq p15, 0, r2, c9, c12, 0 // write PMNC 48 | mov r2, #1 << 31 // enable cycle counter 49 | mcr p15, 0, r2, c9, c12, 1 // write CNTENS 50 | bx lr 51 | endfunc 52 | 53 | function cpu_disable_armv7_counter, export=0 54 | mrc p15, 0, r0, c9, c12, 0 // read PMNC 55 | bic r0, r0, #1 // disable counters 56 | mcr p15, 0, r0, c9, c12, 0 // write PMNC 57 | bx lr 58 | endfunc 59 | 60 | 61 | .macro READ_TIME r 62 | mrc p15, 0, \r, c9, c13, 0 63 | .endm 64 | 65 | // return: 0 if transfers neon -> arm transfers take more than 10 cycles 66 | // nonzero otherwise 67 | function cpu_fast_neon_mrc_test 68 | // check for user access to performance counters 69 | mrc p15, 0, r0, c9, c14, 0 70 | cmp r0, #0 71 | bxeq lr 72 | 73 | push {r4-r6,lr} 74 | bl cpu_enable_armv7_counter 75 | ands r1, r0, #8 76 | mov r3, #0 77 | mov ip, #4 78 | mov r6, #4 79 | moveq r5, #1 80 | movne r5, #64 81 | 82 | average_loop: 83 | mov r4, r5 84 | READ_TIME r1 85 | 1: subs r4, r4, #1 86 | .rept 8 87 | vmov.u32 lr, d0[0] 88 | add lr, lr, lr 89 | .endr 90 | bgt 1b 91 | READ_TIME r2 92 | 93 | subs r6, r6, #1 94 | sub r2, r2, r1 95 | cmpgt r2, #30 << 3 // assume context switch if it took over 30 cycles 96 | addle r3, r3, r2 97 | subsle ip, ip, #1 98 | bgt average_loop 99 | 100 | // disable counters if we enabled them 101 | ands r0, r0, #1 102 | bleq cpu_disable_armv7_counter 103 | 104 | lsr r0, r3, #5 105 | cmp r0, #10 106 | movgt r0, #0 107 | pop {r4-r6,pc} 108 | endfunc 109 | -------------------------------------------------------------------------------- /x264c/external/x264/common/mips/predict.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * predict.h: msa intra prediction 3 | ***************************************************************************** 4 | * Copyright (C) 2015-2022 x264 project 5 | * 6 | * Authors: Rishikesh More 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_MIPS_PREDICT_H 27 | #define X264_MIPS_PREDICT_H 28 | 29 | #define x264_intra_predict_dc_16x16_msa x264_template(intra_predict_dc_16x16_msa) 30 | void x264_intra_predict_dc_16x16_msa( uint8_t *p_src ); 31 | #define x264_intra_predict_dc_left_16x16_msa x264_template(intra_predict_dc_left_16x16_msa) 32 | void x264_intra_predict_dc_left_16x16_msa( uint8_t *p_src ); 33 | #define x264_intra_predict_dc_top_16x16_msa x264_template(intra_predict_dc_top_16x16_msa) 34 | void x264_intra_predict_dc_top_16x16_msa( uint8_t *p_src ); 35 | #define x264_intra_predict_dc_128_16x16_msa x264_template(intra_predict_dc_128_16x16_msa) 36 | void x264_intra_predict_dc_128_16x16_msa( uint8_t *p_src ); 37 | #define x264_intra_predict_hor_16x16_msa x264_template(intra_predict_hor_16x16_msa) 38 | void x264_intra_predict_hor_16x16_msa( uint8_t *p_src ); 39 | #define x264_intra_predict_vert_16x16_msa x264_template(intra_predict_vert_16x16_msa) 40 | void x264_intra_predict_vert_16x16_msa( uint8_t *p_src ); 41 | #define x264_intra_predict_plane_16x16_msa x264_template(intra_predict_plane_16x16_msa) 42 | void x264_intra_predict_plane_16x16_msa( uint8_t *p_src ); 43 | #define x264_intra_predict_dc_4blk_8x8_msa x264_template(intra_predict_dc_4blk_8x8_msa) 44 | void x264_intra_predict_dc_4blk_8x8_msa( uint8_t *p_src ); 45 | #define x264_intra_predict_hor_8x8_msa x264_template(intra_predict_hor_8x8_msa) 46 | void x264_intra_predict_hor_8x8_msa( uint8_t *p_src ); 47 | #define x264_intra_predict_vert_8x8_msa x264_template(intra_predict_vert_8x8_msa) 48 | void x264_intra_predict_vert_8x8_msa( uint8_t *p_src ); 49 | #define x264_intra_predict_plane_8x8_msa x264_template(intra_predict_plane_8x8_msa) 50 | void x264_intra_predict_plane_8x8_msa( uint8_t *p_src ); 51 | #define x264_intra_predict_ddl_8x8_msa x264_template(intra_predict_ddl_8x8_msa) 52 | void x264_intra_predict_ddl_8x8_msa( uint8_t *p_src, uint8_t pu_xyz[36] ); 53 | #define x264_intra_predict_dc_8x8_msa x264_template(intra_predict_dc_8x8_msa) 54 | void x264_intra_predict_dc_8x8_msa( uint8_t *p_src, uint8_t pu_xyz[36] ); 55 | #define x264_intra_predict_h_8x8_msa x264_template(intra_predict_h_8x8_msa) 56 | void x264_intra_predict_h_8x8_msa( uint8_t *p_src, uint8_t pu_xyz[36] ); 57 | #define x264_intra_predict_v_8x8_msa x264_template(intra_predict_v_8x8_msa) 58 | void x264_intra_predict_v_8x8_msa( uint8_t *p_src, uint8_t pu_xyz[36] ); 59 | #define x264_intra_predict_dc_4x4_msa x264_template(intra_predict_dc_4x4_msa) 60 | void x264_intra_predict_dc_4x4_msa( uint8_t *p_src ); 61 | #define x264_intra_predict_hor_4x4_msa x264_template(intra_predict_hor_4x4_msa) 62 | void x264_intra_predict_hor_4x4_msa( uint8_t *p_src ); 63 | #define x264_intra_predict_vert_4x4_msa x264_template(intra_predict_vert_4x4_msa) 64 | void x264_intra_predict_vert_4x4_msa( uint8_t *p_src ); 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /x264c/external/x264/common/ppc/dct.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * dct.h: ppc transform and zigzag 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2022 x264 project 5 | * 6 | * Authors: Eric Petit 7 | * Guillaume Poirier 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 22 | * 23 | * This program is also available under a commercial proprietary license. 24 | * For more information, contact us at licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #ifndef X264_PPC_DCT_H 28 | #define X264_PPC_DCT_H 29 | 30 | #define x264_sub4x4_dct_altivec x264_template(sub4x4_dct_altivec) 31 | void x264_sub4x4_dct_altivec( int16_t dct[16], uint8_t *pix1, uint8_t *pix2 ); 32 | #define x264_sub8x8_dct_altivec x264_template(sub8x8_dct_altivec) 33 | void x264_sub8x8_dct_altivec( int16_t dct[4][16], uint8_t *pix1, uint8_t *pix2 ); 34 | #define x264_sub16x16_dct_altivec x264_template(sub16x16_dct_altivec) 35 | void x264_sub16x16_dct_altivec( int16_t dct[16][16], uint8_t *pix1, uint8_t *pix2 ); 36 | 37 | #define x264_add8x8_idct_dc_altivec x264_template(add8x8_idct_dc_altivec) 38 | void x264_add8x8_idct_dc_altivec( uint8_t *p_dst, int16_t dct[4] ); 39 | #define x264_add16x16_idct_dc_altivec x264_template(add16x16_idct_dc_altivec) 40 | void x264_add16x16_idct_dc_altivec( uint8_t *p_dst, int16_t dct[16] ); 41 | 42 | #define x264_add4x4_idct_altivec x264_template(add4x4_idct_altivec) 43 | void x264_add4x4_idct_altivec( uint8_t *p_dst, int16_t dct[16] ); 44 | #define x264_add8x8_idct_altivec x264_template(add8x8_idct_altivec) 45 | void x264_add8x8_idct_altivec( uint8_t *p_dst, int16_t dct[4][16] ); 46 | #define x264_add16x16_idct_altivec x264_template(add16x16_idct_altivec) 47 | void x264_add16x16_idct_altivec( uint8_t *p_dst, int16_t dct[16][16] ); 48 | 49 | #define x264_sub8x8_dct_dc_altivec x264_template(sub8x8_dct_dc_altivec) 50 | void x264_sub8x8_dct_dc_altivec( int16_t dct[4], uint8_t *pix1, uint8_t *pix2 ); 51 | #define x264_sub8x8_dct8_altivec x264_template(sub8x8_dct8_altivec) 52 | void x264_sub8x8_dct8_altivec( int16_t dct[64], uint8_t *pix1, uint8_t *pix2 ); 53 | #define x264_sub16x16_dct8_altivec x264_template(sub16x16_dct8_altivec) 54 | void x264_sub16x16_dct8_altivec( int16_t dct[4][64], uint8_t *pix1, uint8_t *pix2 ); 55 | 56 | #define x264_add8x8_idct8_altivec x264_template(add8x8_idct8_altivec) 57 | void x264_add8x8_idct8_altivec( uint8_t *dst, int16_t dct[64] ); 58 | #define x264_add16x16_idct8_altivec x264_template(add16x16_idct8_altivec) 59 | void x264_add16x16_idct8_altivec( uint8_t *dst, int16_t dct[4][64] ); 60 | 61 | #define x264_zigzag_scan_4x4_frame_altivec x264_template(zigzag_scan_4x4_frame_altivec) 62 | void x264_zigzag_scan_4x4_frame_altivec( int16_t level[16], int16_t dct[16] ); 63 | #define x264_zigzag_scan_4x4_field_altivec x264_template(zigzag_scan_4x4_field_altivec) 64 | void x264_zigzag_scan_4x4_field_altivec( int16_t level[16], int16_t dct[16] ); 65 | #define x264_zigzag_scan_8x8_frame_altivec x264_template(zigzag_scan_8x8_frame_altivec) 66 | void x264_zigzag_scan_8x8_frame_altivec( int16_t level[64], int16_t dct[64] ); 67 | #define x264_zigzag_interleave_8x8_cavlc_altivec x264_template(zigzag_interleave_8x8_cavlc_altivec) 68 | void x264_zigzag_interleave_8x8_cavlc_altivec( int16_t *dst, int16_t *src, uint8_t *nnz ); 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /x264c/external/x264/common/opencl/x264-cl.h: -------------------------------------------------------------------------------- 1 | #pragma OPENCL EXTENSION cl_khr_local_int32_extended_atomics : enable 2 | 3 | constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST; 4 | 5 | /* 7.18.1.1 Exact-width integer types */ 6 | typedef signed char int8_t; 7 | typedef unsigned char uint8_t; 8 | typedef short int16_t; 9 | typedef unsigned short uint16_t; 10 | typedef int int32_t; 11 | typedef unsigned uint32_t; 12 | 13 | typedef uint8_t pixel; 14 | typedef uint16_t sum_t; 15 | typedef uint32_t sum2_t; 16 | 17 | #define LOWRES_COST_MASK ((1<<14)-1) 18 | #define LOWRES_COST_SHIFT 14 19 | #define COST_MAX (1<<28) 20 | 21 | #define PIXEL_MAX 255 22 | #define BITS_PER_SUM (8 * sizeof(sum_t)) 23 | 24 | /* Constants for offsets into frame statistics buffer */ 25 | #define COST_EST 0 26 | #define COST_EST_AQ 1 27 | #define INTRA_MBS 2 28 | 29 | #define COPY2_IF_LT( x, y, a, b )\ 30 | if( (y) < (x) )\ 31 | {\ 32 | (x) = (y);\ 33 | (a) = (b);\ 34 | } 35 | 36 | constant int2 dia_offs[4] = 37 | { 38 | {0, -1}, {-1, 0}, {1, 0}, {0, 1}, 39 | }; 40 | 41 | inline pixel x264_clip_pixel( int x ) 42 | { 43 | return (pixel) clamp( x, (int) 0, (int) PIXEL_MAX ); 44 | } 45 | 46 | inline int2 x264_median_mv( short2 a, short2 b, short2 c ) 47 | { 48 | short2 t1 = min(a, b); 49 | short2 t2 = min(max(a, b), c); 50 | return convert_int2(max(t1, t2)); 51 | } 52 | 53 | inline sum2_t abs2( sum2_t a ) 54 | { 55 | sum2_t s = ((a >> (BITS_PER_SUM - 1)) & (((sum2_t)1 << BITS_PER_SUM) + 1)) * ((sum_t)-1); 56 | return (a + s) ^ s; 57 | } 58 | 59 | #define HADAMARD4( d0, d1, d2, d3, s0, s1, s2, s3 ) {\ 60 | sum2_t t0 = s0 + s1;\ 61 | sum2_t t1 = s0 - s1;\ 62 | sum2_t t2 = s2 + s3;\ 63 | sum2_t t3 = s2 - s3;\ 64 | d0 = t0 + t2;\ 65 | d2 = t0 - t2;\ 66 | d1 = t1 + t3;\ 67 | d3 = t1 - t3;\ 68 | } 69 | 70 | #define HADAMARD4V( d0, d1, d2, d3, s0, s1, s2, s3 ) {\ 71 | int2 t0 = s0 + s1;\ 72 | int2 t1 = s0 - s1;\ 73 | int2 t2 = s2 + s3;\ 74 | int2 t3 = s2 - s3;\ 75 | d0 = t0 + t2;\ 76 | d2 = t0 - t2;\ 77 | d1 = t1 + t3;\ 78 | d3 = t1 - t3;\ 79 | } 80 | 81 | #define SATD_C_8x4_Q( name, q1, q2 )\ 82 | int name( q1 pixel *pix1, int i_pix1, q2 pixel *pix2, int i_pix2 )\ 83 | {\ 84 | sum2_t tmp[4][4];\ 85 | sum2_t a0, a1, a2, a3;\ 86 | sum2_t sum = 0;\ 87 | for( int i = 0; i < 4; i++, pix1 += i_pix1, pix2 += i_pix2 )\ 88 | {\ 89 | a0 = (pix1[0] - pix2[0]) + ((sum2_t)(pix1[4] - pix2[4]) << BITS_PER_SUM);\ 90 | a1 = (pix1[1] - pix2[1]) + ((sum2_t)(pix1[5] - pix2[5]) << BITS_PER_SUM);\ 91 | a2 = (pix1[2] - pix2[2]) + ((sum2_t)(pix1[6] - pix2[6]) << BITS_PER_SUM);\ 92 | a3 = (pix1[3] - pix2[3]) + ((sum2_t)(pix1[7] - pix2[7]) << BITS_PER_SUM);\ 93 | HADAMARD4( tmp[i][0], tmp[i][1], tmp[i][2], tmp[i][3], a0, a1, a2, a3 );\ 94 | }\ 95 | for( int i = 0; i < 4; i++ )\ 96 | {\ 97 | HADAMARD4( a0, a1, a2, a3, tmp[0][i], tmp[1][i], tmp[2][i], tmp[3][i] );\ 98 | sum += abs2( a0 ) + abs2( a1 ) + abs2( a2 ) + abs2( a3 );\ 99 | }\ 100 | return (((sum_t)sum) + (sum>>BITS_PER_SUM)) >> 1;\ 101 | } 102 | 103 | /* 104 | * Utility function to perform a parallel sum reduction of an array of integers 105 | */ 106 | int parallel_sum( int value, int x, volatile local int *array ) 107 | { 108 | array[x] = value; 109 | barrier( CLK_LOCAL_MEM_FENCE ); 110 | 111 | int dim = get_local_size( 0 ); 112 | 113 | while( dim > 1 ) 114 | { 115 | dim >>= 1; 116 | 117 | if( x < dim ) 118 | array[x] += array[x + dim]; 119 | 120 | if( dim > 32 ) 121 | barrier( CLK_LOCAL_MEM_FENCE ); 122 | } 123 | 124 | return array[0]; 125 | } 126 | 127 | int mv_cost( uint2 mvd ) 128 | { 129 | float2 mvdf = (float2)(mvd.x, mvd.y) + 1.0f; 130 | float2 cost = round( log2(mvdf) * 2.0f + 0.718f + (float2)(!!mvd.x, !!mvd.y) ); 131 | return (int) (cost.x + cost.y); 132 | } 133 | -------------------------------------------------------------------------------- /x264c/external/x264/encoder/set.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * set.h: header writing 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2022 x264 project 5 | * 6 | * Authors: Laurent Aimar 7 | * Loren Merritt 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 22 | * 23 | * This program is also available under a commercial proprietary license. 24 | * For more information, contact us at licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #ifndef X264_ENCODER_SET_H 28 | #define X264_ENCODER_SET_H 29 | 30 | #define x264_sps_init x264_template(sps_init) 31 | void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param ); 32 | #define x264_sps_init_reconfigurable x264_template(sps_init_reconfigurable) 33 | void x264_sps_init_reconfigurable( x264_sps_t *sps, x264_param_t *param ); 34 | #define x264_sps_init_scaling_list x264_template(sps_init_scaling_list) 35 | void x264_sps_init_scaling_list( x264_sps_t *sps, x264_param_t *param ); 36 | #define x264_sps_write x264_template(sps_write) 37 | void x264_sps_write( bs_t *s, x264_sps_t *sps ); 38 | #define x264_pps_init x264_template(pps_init) 39 | void x264_pps_init( x264_pps_t *pps, int i_id, x264_param_t *param, x264_sps_t *sps ); 40 | #define x264_pps_write x264_template(pps_write) 41 | void x264_pps_write( bs_t *s, x264_sps_t *sps, x264_pps_t *pps ); 42 | #define x264_sei_recovery_point_write x264_template(sei_recovery_point_write) 43 | void x264_sei_recovery_point_write( x264_t *h, bs_t *s, int recovery_frame_cnt ); 44 | #define x264_sei_version_write x264_template(sei_version_write) 45 | int x264_sei_version_write( x264_t *h, bs_t *s ); 46 | #define x264_validate_levels x264_template(validate_levels) 47 | int x264_validate_levels( x264_t *h, int verbose ); 48 | #define x264_sei_buffering_period_write x264_template(sei_buffering_period_write) 49 | void x264_sei_buffering_period_write( x264_t *h, bs_t *s ); 50 | #define x264_sei_pic_timing_write x264_template(sei_pic_timing_write) 51 | void x264_sei_pic_timing_write( x264_t *h, bs_t *s ); 52 | #define x264_sei_dec_ref_pic_marking_write x264_template(sei_dec_ref_pic_marking_write) 53 | void x264_sei_dec_ref_pic_marking_write( x264_t *h, bs_t *s ); 54 | #define x264_sei_frame_packing_write x264_template(sei_frame_packing_write) 55 | void x264_sei_frame_packing_write( x264_t *h, bs_t *s ); 56 | #define x264_sei_mastering_display_write x264_template(sei_mastering_display_write) 57 | void x264_sei_mastering_display_write( x264_t *h, bs_t *s ); 58 | #define x264_sei_content_light_level_write x264_template(sei_content_light_level_write) 59 | void x264_sei_content_light_level_write( x264_t *h, bs_t *s ); 60 | #define x264_sei_alternative_transfer_write x264_template(sei_alternative_transfer_write) 61 | void x264_sei_alternative_transfer_write( x264_t *h, bs_t *s ); 62 | #define x264_sei_avcintra_umid_write x264_template(sei_avcintra_umid_write) 63 | int x264_sei_avcintra_umid_write( x264_t *h, bs_t *s ); 64 | #define x264_sei_avcintra_vanc_write x264_template(sei_avcintra_vanc_write) 65 | int x264_sei_avcintra_vanc_write( x264_t *h, bs_t *s, int len ); 66 | #define x264_sei_write x264_template(sei_write) 67 | void x264_sei_write( bs_t *s, uint8_t *payload, int payload_size, int payload_type ); 68 | #define x264_filler_write x264_template(filler_write) 69 | void x264_filler_write( x264_t *h, bs_t *s, int filler ); 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /x264c/external/x264/encoder/me.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * me.h: motion estimation 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2022 x264 project 5 | * 6 | * Authors: Loren Merritt 7 | * Laurent Aimar 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 22 | * 23 | * This program is also available under a commercial proprietary license. 24 | * For more information, contact us at licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #ifndef X264_ENCODER_ME_H 28 | #define X264_ENCODER_ME_H 29 | 30 | #define COST_MAX (1<<28) 31 | #define COST_MAX64 (1ULL<<60) 32 | 33 | typedef struct 34 | { 35 | /* aligning the first member is a gcc hack to force the struct to be aligned, 36 | * as well as force sizeof(struct) to be a multiple of the alignment. */ 37 | /* input */ 38 | ALIGNED_64( int i_pixel ); /* PIXEL_WxH */ 39 | uint16_t *p_cost_mv; /* lambda * nbits for each possible mv */ 40 | int i_ref_cost; 41 | int i_ref; 42 | const x264_weight_t *weight; 43 | 44 | pixel *p_fref[12]; 45 | pixel *p_fref_w; 46 | pixel *p_fenc[3]; 47 | uint16_t *integral; 48 | int i_stride[3]; 49 | 50 | ALIGNED_4( int16_t mvp[2] ); 51 | 52 | /* output */ 53 | int cost_mv; /* lambda * nbits for the chosen mv */ 54 | int cost; /* satd + lambda * nbits */ 55 | ALIGNED_8( int16_t mv[2] ); 56 | } ALIGNED_64( x264_me_t ); 57 | 58 | #define x264_me_search_ref x264_template(me_search_ref) 59 | void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc, int *p_fullpel_thresh ); 60 | #define x264_me_search( h, m, mvc, i_mvc )\ 61 | x264_me_search_ref( h, m, mvc, i_mvc, NULL ) 62 | 63 | #define x264_me_refine_qpel x264_template(me_refine_qpel) 64 | void x264_me_refine_qpel( x264_t *h, x264_me_t *m ); 65 | #define x264_me_refine_qpel_refdupe x264_template(me_refine_qpel_refdupe) 66 | void x264_me_refine_qpel_refdupe( x264_t *h, x264_me_t *m, int *p_halfpel_thresh ); 67 | #define x264_me_refine_qpel_rd x264_template(me_refine_qpel_rd) 68 | void x264_me_refine_qpel_rd( x264_t *h, x264_me_t *m, int i_lambda2, int i4, int i_list ); 69 | #define x264_me_refine_bidir_rd x264_template(me_refine_bidir_rd) 70 | void x264_me_refine_bidir_rd( x264_t *h, x264_me_t *m0, x264_me_t *m1, int i_weight, int i8, int i_lambda2 ); 71 | #define x264_me_refine_bidir_satd x264_template(me_refine_bidir_satd) 72 | void x264_me_refine_bidir_satd( x264_t *h, x264_me_t *m0, x264_me_t *m1, int i_weight ); 73 | #define x264_rd_cost_part x264_template(rd_cost_part) 74 | uint64_t x264_rd_cost_part( x264_t *h, int i_lambda2, int i8, int i_pixel ); 75 | 76 | #define COPY1_IF_LT(x,y)\ 77 | if( (y) < (x) )\ 78 | (x) = (y); 79 | 80 | #define COPY2_IF_LT(x,y,a,b)\ 81 | if( (y) < (x) )\ 82 | {\ 83 | (x) = (y);\ 84 | (a) = (b);\ 85 | } 86 | 87 | #define COPY3_IF_LT(x,y,a,b,c,d)\ 88 | if( (y) < (x) )\ 89 | {\ 90 | (x) = (y);\ 91 | (a) = (b);\ 92 | (c) = (d);\ 93 | } 94 | 95 | #define COPY4_IF_LT(x,y,a,b,c,d,e,f)\ 96 | if( (y) < (x) )\ 97 | {\ 98 | (x) = (y);\ 99 | (a) = (b);\ 100 | (c) = (d);\ 101 | (e) = (f);\ 102 | } 103 | 104 | #define COPY2_IF_GT(x,y,a,b)\ 105 | if( (y) > (x) )\ 106 | {\ 107 | (x) = (y);\ 108 | (a) = (b);\ 109 | } 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /x264c/external/x264/common/vlc.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * vlc.c : vlc tables 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2022 x264 project 5 | * 6 | * Authors: Laurent Aimar 7 | * Fiona Glaser 8 | * Henrik Gramner 9 | * 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program; if not, write to the Free Software 22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 23 | * 24 | * This program is also available under a commercial proprietary license. 25 | * For more information, contact us at licensing@x264.com. 26 | *****************************************************************************/ 27 | 28 | #include "common.h" 29 | 30 | vlc_large_t x264_level_token[7][LEVEL_TABLE_SIZE]; 31 | uint32_t x264_run_before[1<<16]; 32 | 33 | void x264_cavlc_init( x264_t *h ) 34 | { 35 | for( int i_suffix = 0; i_suffix < 7; i_suffix++ ) 36 | for( int16_t level = -LEVEL_TABLE_SIZE/2; level < LEVEL_TABLE_SIZE/2; level++ ) 37 | { 38 | int mask = level >> 15; 39 | int abs_level = (level^mask)-mask; 40 | int i_level_code = abs_level ? abs_level*2-mask-2 : 0; 41 | int i_next = i_suffix; 42 | vlc_large_t *vlc = &x264_level_token[i_suffix][level+LEVEL_TABLE_SIZE/2]; 43 | 44 | if( ( i_level_code >> i_suffix ) < 14 ) 45 | { 46 | vlc->i_size = (i_level_code >> i_suffix) + 1 + i_suffix; 47 | vlc->i_bits = (1<i_size = 19; 52 | vlc->i_bits = (1<<4) + (i_level_code - 14); 53 | } 54 | else if( i_suffix > 0 && ( i_level_code >> i_suffix ) == 14 ) 55 | { 56 | vlc->i_size = 15 + i_suffix; 57 | vlc->i_bits = (1<i_size = 28; 65 | vlc->i_bits = (1<<12) + i_level_code; 66 | } 67 | if( i_next == 0 ) 68 | i_next++; 69 | if( abs_level > (3 << (i_next-1)) && i_next < 6 ) 70 | i_next++; 71 | vlc->i_next = i_next; 72 | } 73 | 74 | x264_run_before[0] = 0; 75 | x264_run_before[1] = 0; 76 | for( uint32_t i = 2; i < (1<<16); i++ ) 77 | { 78 | x264_run_level_t runlevel; 79 | ALIGNED_ARRAY_16( dctcoef, dct, [16] ); 80 | int size = 0; 81 | int bits = 0; 82 | for( int j = 0; j < 16; j++ ) 83 | dct[j] = i&(1<quantf.coeff_level_run[DCT_LUMA_4x4]( dct, &runlevel ); 85 | int zeros = runlevel.last + 1 - total; 86 | uint32_t mask = i << (x264_clz( i ) + 1); 87 | for( int j = 0; j < total-1 && zeros > 0; j++ ) 88 | { 89 | int idx = X264_MIN(zeros, 7) - 1; 90 | int run = x264_clz( mask ); 91 | int len = x264_run_before_init[idx][run].i_size; 92 | size += len; 93 | bits <<= len; 94 | bits |= x264_run_before_init[idx][run].i_bits; 95 | zeros -= run; 96 | mask <<= run + 1; 97 | } 98 | x264_run_before[i] = (bits << 5) + size; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /x264c/external/x264/common/aarch64/quant.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * quant.h: arm quantization and level-run 3 | ***************************************************************************** 4 | * Copyright (C) 2005-2022 x264 project 5 | * 6 | * Authors: David Conrad 7 | * Janne Grunau 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 22 | * 23 | * This program is also available under a commercial proprietary license. 24 | * For more information, contact us at licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #ifndef X264_AARCH64_QUANT_H 28 | #define X264_AARCH64_QUANT_H 29 | 30 | #define x264_quant_2x2_dc_aarch64 x264_template(quant_2x2_dc_aarch64) 31 | int x264_quant_2x2_dc_aarch64( int16_t dct[4], int mf, int bias ); 32 | 33 | #define x264_quant_2x2_dc_neon x264_template(quant_2x2_dc_neon) 34 | int x264_quant_2x2_dc_neon( int16_t dct[4], int mf, int bias ); 35 | #define x264_quant_4x4_dc_neon x264_template(quant_4x4_dc_neon) 36 | int x264_quant_4x4_dc_neon( int16_t dct[16], int mf, int bias ); 37 | #define x264_quant_4x4_neon x264_template(quant_4x4_neon) 38 | int x264_quant_4x4_neon( int16_t dct[16], uint16_t mf[16], uint16_t bias[16] ); 39 | #define x264_quant_4x4x4_neon x264_template(quant_4x4x4_neon) 40 | int x264_quant_4x4x4_neon( int16_t dct[4][16], uint16_t mf[16], uint16_t bias[16] ); 41 | #define x264_quant_8x8_neon x264_template(quant_8x8_neon) 42 | int x264_quant_8x8_neon( int16_t dct[64], uint16_t mf[64], uint16_t bias[64] ); 43 | 44 | #define x264_dequant_4x4_dc_neon x264_template(dequant_4x4_dc_neon) 45 | void x264_dequant_4x4_dc_neon( int16_t dct[16], int dequant_mf[6][16], int i_qp ); 46 | #define x264_dequant_4x4_neon x264_template(dequant_4x4_neon) 47 | void x264_dequant_4x4_neon( int16_t dct[16], int dequant_mf[6][16], int i_qp ); 48 | #define x264_dequant_8x8_neon x264_template(dequant_8x8_neon) 49 | void x264_dequant_8x8_neon( int16_t dct[64], int dequant_mf[6][64], int i_qp ); 50 | 51 | #define x264_decimate_score15_neon x264_template(decimate_score15_neon) 52 | int x264_decimate_score15_neon( int16_t * ); 53 | #define x264_decimate_score16_neon x264_template(decimate_score16_neon) 54 | int x264_decimate_score16_neon( int16_t * ); 55 | #define x264_decimate_score64_neon x264_template(decimate_score64_neon) 56 | int x264_decimate_score64_neon( int16_t * ); 57 | 58 | #define x264_coeff_last4_aarch64 x264_template(coeff_last4_aarch64) 59 | int x264_coeff_last4_aarch64( int16_t * ); 60 | #define x264_coeff_last8_aarch64 x264_template(coeff_last8_aarch64) 61 | int x264_coeff_last8_aarch64( int16_t * ); 62 | #define x264_coeff_last15_neon x264_template(coeff_last15_neon) 63 | int x264_coeff_last15_neon( int16_t * ); 64 | #define x264_coeff_last16_neon x264_template(coeff_last16_neon) 65 | int x264_coeff_last16_neon( int16_t * ); 66 | #define x264_coeff_last64_neon x264_template(coeff_last64_neon) 67 | int x264_coeff_last64_neon( int16_t * ); 68 | 69 | #define x264_coeff_level_run4_aarch64 x264_template(coeff_level_run4_aarch64) 70 | int x264_coeff_level_run4_aarch64( int16_t *, x264_run_level_t * ); 71 | #define x264_coeff_level_run8_neon x264_template(coeff_level_run8_neon) 72 | int x264_coeff_level_run8_neon( int16_t *, x264_run_level_t * ); 73 | #define x264_coeff_level_run15_neon x264_template(coeff_level_run15_neon) 74 | int x264_coeff_level_run15_neon( int16_t *, x264_run_level_t * ); 75 | #define x264_coeff_level_run16_neon x264_template(coeff_level_run16_neon) 76 | int x264_coeff_level_run16_neon( int16_t *, x264_run_level_t * ); 77 | 78 | #define x264_denoise_dct_neon x264_template(denoise_dct_neon) 79 | void x264_denoise_dct_neon( dctcoef *, uint32_t *, udctcoef *, int ); 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /x264c/external/x264/common/arm/predict-c.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * predict.c: arm intra prediction 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2022 x264 project 5 | * 6 | * Authors: David Conrad 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #include "common/common.h" 27 | #include "predict.h" 28 | #include "pixel.h" 29 | 30 | void x264_predict_4x4_init_arm( uint32_t cpu, x264_predict_t pf[12] ) 31 | { 32 | if( !(cpu&X264_CPU_ARMV6) ) 33 | return; 34 | 35 | #if !HIGH_BIT_DEPTH 36 | pf[I_PRED_4x4_H] = x264_predict_4x4_h_armv6; 37 | pf[I_PRED_4x4_V] = x264_predict_4x4_v_armv6; 38 | pf[I_PRED_4x4_DC] = x264_predict_4x4_dc_armv6; 39 | pf[I_PRED_4x4_DDR] = x264_predict_4x4_ddr_armv6; 40 | 41 | if( !(cpu&X264_CPU_NEON) ) 42 | return; 43 | 44 | pf[I_PRED_4x4_DC_TOP] = x264_predict_4x4_dc_top_neon; 45 | pf[I_PRED_4x4_DDL] = x264_predict_4x4_ddl_neon; 46 | #endif // !HIGH_BIT_DEPTH 47 | } 48 | 49 | void x264_predict_8x8c_init_arm( uint32_t cpu, x264_predict_t pf[7] ) 50 | { 51 | if( !(cpu&X264_CPU_NEON) ) 52 | return; 53 | 54 | #if !HIGH_BIT_DEPTH 55 | pf[I_PRED_CHROMA_DC] = x264_predict_8x8c_dc_neon; 56 | pf[I_PRED_CHROMA_DC_TOP] = x264_predict_8x8c_dc_top_neon; 57 | pf[I_PRED_CHROMA_DC_LEFT] = x264_predict_8x8c_dc_left_neon; 58 | pf[I_PRED_CHROMA_H] = x264_predict_8x8c_h_neon; 59 | pf[I_PRED_CHROMA_V] = x264_predict_8x8c_v_neon; 60 | pf[I_PRED_CHROMA_P] = x264_predict_8x8c_p_neon; 61 | #endif // !HIGH_BIT_DEPTH 62 | } 63 | 64 | void x264_predict_8x16c_init_arm( uint32_t cpu, x264_predict_t pf[7] ) 65 | { 66 | if( !(cpu&X264_CPU_NEON) ) 67 | return; 68 | 69 | #if !HIGH_BIT_DEPTH 70 | /* The other functions weren't faster than C (gcc 4.7.3) on Cortex A8 and A9. */ 71 | pf[I_PRED_CHROMA_DC_TOP] = x264_predict_8x16c_dc_top_neon; 72 | pf[I_PRED_CHROMA_H] = x264_predict_8x16c_h_neon; 73 | pf[I_PRED_CHROMA_P] = x264_predict_8x16c_p_neon; 74 | #endif // !HIGH_BIT_DEPTH 75 | } 76 | 77 | void x264_predict_8x8_init_arm( uint32_t cpu, x264_predict8x8_t pf[12], x264_predict_8x8_filter_t *predict_filter ) 78 | { 79 | if( !(cpu&X264_CPU_NEON) ) 80 | return; 81 | 82 | #if !HIGH_BIT_DEPTH 83 | pf[I_PRED_8x8_DDL] = x264_predict_8x8_ddl_neon; 84 | pf[I_PRED_8x8_DDR] = x264_predict_8x8_ddr_neon; 85 | pf[I_PRED_8x8_VL] = x264_predict_8x8_vl_neon; 86 | pf[I_PRED_8x8_VR] = x264_predict_8x8_vr_neon; 87 | pf[I_PRED_8x8_DC] = x264_predict_8x8_dc_neon; 88 | pf[I_PRED_8x8_H] = x264_predict_8x8_h_neon; 89 | pf[I_PRED_8x8_HD] = x264_predict_8x8_hd_neon; 90 | pf[I_PRED_8x8_HU] = x264_predict_8x8_hu_neon; 91 | pf[I_PRED_8x8_V] = x264_predict_8x8_v_neon; 92 | #endif // !HIGH_BIT_DEPTH 93 | } 94 | 95 | void x264_predict_16x16_init_arm( uint32_t cpu, x264_predict_t pf[7] ) 96 | { 97 | if( !(cpu&X264_CPU_NEON) ) 98 | return; 99 | 100 | #if !HIGH_BIT_DEPTH 101 | pf[I_PRED_16x16_DC ] = x264_predict_16x16_dc_neon; 102 | pf[I_PRED_16x16_DC_TOP] = x264_predict_16x16_dc_top_neon; 103 | pf[I_PRED_16x16_DC_LEFT]= x264_predict_16x16_dc_left_neon; 104 | pf[I_PRED_16x16_H ] = x264_predict_16x16_h_neon; 105 | pf[I_PRED_16x16_V ] = x264_predict_16x16_v_neon; 106 | pf[I_PRED_16x16_P ] = x264_predict_16x16_p_neon; 107 | #endif // !HIGH_BIT_DEPTH 108 | } 109 | -------------------------------------------------------------------------------- /x264c/external/x264/common/x86/bitstream-a.asm: -------------------------------------------------------------------------------- 1 | ;***************************************************************************** 2 | ;* bitstream-a.asm: x86 bitstream functions 3 | ;***************************************************************************** 4 | ;* Copyright (C) 2010-2022 x264 project 5 | ;* 6 | ;* Authors: Fiona Glaser 7 | ;* Henrik Gramner 8 | ;* 9 | ;* This program is free software; you can redistribute it and/or modify 10 | ;* it under the terms of the GNU General Public License as published by 11 | ;* the Free Software Foundation; either version 2 of the License, or 12 | ;* (at your option) any later version. 13 | ;* 14 | ;* This program is distributed in the hope that it will be useful, 15 | ;* but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ;* GNU General Public License for more details. 18 | ;* 19 | ;* You should have received a copy of the GNU General Public License 20 | ;* along with this program; if not, write to the Free Software 21 | ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 22 | ;* 23 | ;* This program is also available under a commercial proprietary license. 24 | ;* For more information, contact us at licensing@x264.com. 25 | ;***************************************************************************** 26 | 27 | %include "x86inc.asm" 28 | %include "x86util.asm" 29 | 30 | SECTION .text 31 | 32 | ;----------------------------------------------------------------------------- 33 | ; uint8_t *x264_nal_escape( uint8_t *dst, uint8_t *src, uint8_t *end ) 34 | ;----------------------------------------------------------------------------- 35 | %macro NAL_LOOP 2 36 | %%escape: 37 | ; Detect false positive to avoid unnecessary escape loop 38 | xor r3d, r3d 39 | cmp byte [r0+r1-1], 0 40 | setnz r3b 41 | xor k3, k4 42 | jnz .escape 43 | jmp %%continue 44 | ALIGN 16 45 | %1: 46 | mova [r0+r1+mmsize], m1 47 | pcmpeqb m1, m0 48 | mova [r0+r1], m2 49 | pcmpeqb m2, m0 50 | pmovmskb r3d, m1 51 | %2 m1, [r1+r2+3*mmsize] 52 | pmovmskb r4d, m2 53 | %2 m2, [r1+r2+2*mmsize] 54 | shl k3, mmsize 55 | or k3, k4 56 | lea k4, [2*r3+1] 57 | and k4, k3 58 | jnz %%escape 59 | %%continue: 60 | add r1, 2*mmsize 61 | jl %1 62 | %endmacro 63 | 64 | %macro NAL_ESCAPE 0 65 | %if mmsize == 32 66 | %xdefine k3 r3 67 | %xdefine k4 r4 68 | %else 69 | %xdefine k3 r3d 70 | %xdefine k4 r4d 71 | %endif 72 | 73 | cglobal nal_escape, 3,5 74 | movzx r3d, byte [r1] 75 | sub r1, r2 ; r1 = offset of current src pointer from end of src 76 | pxor m0, m0 77 | mov [r0], r3b 78 | sub r0, r1 ; r0 = projected end of dst, assuming no more escapes 79 | or r3d, 0xffffff00 ; ignore data before src 80 | 81 | ; Start off by jumping into the escape loop in case there's an escape at the start. 82 | ; And do a few more in scalar until dst is aligned. 83 | jmp .escape_loop 84 | 85 | %if mmsize == 16 86 | NAL_LOOP .loop_aligned, mova 87 | jmp .ret 88 | %endif 89 | NAL_LOOP .loop_unaligned, movu 90 | .ret: 91 | movifnidn rax, r0 92 | RET 93 | 94 | .escape: 95 | ; Skip bytes that are known to be valid 96 | and k4, k3 97 | tzcnt k4, k4 98 | xor r3d, r3d ; the last two bytes are known to be zero 99 | add r1, r4 100 | .escape_loop: 101 | inc r1 102 | jge .ret 103 | movzx r4d, byte [r1+r2] 104 | shl r3d, 8 105 | or r3d, r4d 106 | test r3d, 0xfffffc ; if the last two bytes are 0 and the current byte is <=3 107 | jz .add_escape_byte 108 | .escaped: 109 | lea r4d, [r0+r1] 110 | mov [r0+r1], r3b 111 | test r4d, mmsize-1 ; Do SIMD when dst is aligned 112 | jnz .escape_loop 113 | movu m1, [r1+r2+mmsize] 114 | movu m2, [r1+r2] 115 | %if mmsize == 16 116 | lea r4d, [r1+r2] 117 | test r4d, mmsize-1 118 | jz .loop_aligned 119 | %endif 120 | jmp .loop_unaligned 121 | 122 | .add_escape_byte: 123 | mov byte [r0+r1], 3 124 | inc r0 125 | or r3d, 0x0300 126 | jmp .escaped 127 | %endmacro 128 | 129 | INIT_MMX mmx2 130 | NAL_ESCAPE 131 | INIT_XMM sse2 132 | NAL_ESCAPE 133 | %if ARCH_X86_64 134 | INIT_YMM avx2 135 | NAL_ESCAPE 136 | %endif 137 | -------------------------------------------------------------------------------- /x264c/external/x264/common/tables.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * tables.h: const tables 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2022 x264 project 5 | * 6 | * Authors: Laurent Aimar 7 | * Loren Merritt 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 22 | * 23 | * This program is also available under a commercial proprietary license. 24 | * For more information, contact us at licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #ifndef X264_TABLES_H 28 | #define X264_TABLES_H 29 | 30 | typedef struct 31 | { 32 | uint8_t i_bits; 33 | uint8_t i_size; 34 | } vlc_t; 35 | 36 | X264_API extern const x264_level_t x264_levels[]; 37 | 38 | extern const uint8_t x264_exp2_lut[64]; 39 | extern const float x264_log2_lut[128]; 40 | extern const float x264_log2_lz_lut[32]; 41 | 42 | #define QP_MAX_MAX (51+6*2+18) 43 | extern const uint16_t x264_lambda_tab[QP_MAX_MAX+1]; 44 | extern const int x264_lambda2_tab[QP_MAX_MAX+1]; 45 | extern const int x264_trellis_lambda2_tab[2][QP_MAX_MAX+1]; 46 | #define MAX_CHROMA_LAMBDA_OFFSET 36 47 | extern const uint16_t x264_chroma_lambda2_offset_tab[MAX_CHROMA_LAMBDA_OFFSET+1]; 48 | 49 | extern const uint8_t x264_hpel_ref0[16]; 50 | extern const uint8_t x264_hpel_ref1[16]; 51 | 52 | extern const uint8_t x264_cqm_jvt4i[16]; 53 | extern const uint8_t x264_cqm_jvt4p[16]; 54 | extern const uint8_t x264_cqm_jvt8i[64]; 55 | extern const uint8_t x264_cqm_jvt8p[64]; 56 | extern const uint8_t x264_cqm_flat16[64]; 57 | extern const uint8_t * const x264_cqm_jvt[8]; 58 | extern const uint8_t x264_cqm_avci50_4ic[16]; 59 | extern const uint8_t x264_cqm_avci50_p_8iy[64]; 60 | extern const uint8_t x264_cqm_avci50_1080i_8iy[64]; 61 | extern const uint8_t x264_cqm_avci100_720p_4ic[16]; 62 | extern const uint8_t x264_cqm_avci100_720p_8iy[64]; 63 | extern const uint8_t x264_cqm_avci100_1080_4ic[16]; 64 | extern const uint8_t x264_cqm_avci100_1080i_8iy[64]; 65 | extern const uint8_t x264_cqm_avci100_1080p_8iy[64]; 66 | extern const uint8_t x264_cqm_avci300_2160p_4iy[16]; 67 | extern const uint8_t x264_cqm_avci300_2160p_4ic[16]; 68 | extern const uint8_t x264_cqm_avci300_2160p_8iy[64]; 69 | 70 | extern const uint8_t x264_decimate_table4[16]; 71 | extern const uint8_t x264_decimate_table8[64]; 72 | 73 | extern const uint32_t x264_dct4_weight_tab[16]; 74 | extern const uint32_t x264_dct8_weight_tab[64]; 75 | extern const uint32_t x264_dct4_weight2_tab[16]; 76 | extern const uint32_t x264_dct8_weight2_tab[64]; 77 | 78 | extern const int8_t x264_cabac_context_init_I[1024][2]; 79 | extern const int8_t x264_cabac_context_init_PB[3][1024][2]; 80 | extern const uint8_t x264_cabac_range_lps[64][4]; 81 | extern const uint8_t x264_cabac_transition[128][2]; 82 | extern const uint8_t x264_cabac_renorm_shift[64]; 83 | extern const uint16_t x264_cabac_entropy[128]; 84 | 85 | extern const uint8_t x264_significant_coeff_flag_offset_8x8[2][64]; 86 | extern const uint8_t x264_last_coeff_flag_offset_8x8[63]; 87 | extern const uint8_t x264_coeff_flag_offset_chroma_422_dc[7]; 88 | extern const uint16_t x264_significant_coeff_flag_offset[2][16]; 89 | extern const uint16_t x264_last_coeff_flag_offset[2][16]; 90 | extern const uint16_t x264_coeff_abs_level_m1_offset[16]; 91 | extern const uint8_t x264_count_cat_m1[14]; 92 | 93 | extern const vlc_t x264_coeff0_token[6]; 94 | extern const vlc_t x264_coeff_token[6][16][4]; 95 | extern const vlc_t x264_total_zeros[15][16]; 96 | extern const vlc_t x264_total_zeros_2x2_dc[3][4]; 97 | extern const vlc_t x264_total_zeros_2x4_dc[7][8]; 98 | extern const vlc_t x264_run_before_init[7][16]; 99 | 100 | extern uint8_t x264_zero[1024]; 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /x264c/external/x264/common/aarch64/predict-c.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * predict.c: aarch64 intra prediction 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2022 x264 project 5 | * 6 | * Authors: David Conrad 7 | * Janne Grunau 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 22 | * 23 | * This program is also available under a commercial proprietary license. 24 | * For more information, contact us at licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #include "common/common.h" 28 | #include "predict.h" 29 | #include "pixel.h" 30 | 31 | void x264_predict_4x4_init_aarch64( uint32_t cpu, x264_predict_t pf[12] ) 32 | { 33 | #if !HIGH_BIT_DEPTH 34 | if( cpu&X264_CPU_ARMV8 ) 35 | { 36 | pf[I_PRED_4x4_H] = x264_predict_4x4_h_aarch64; 37 | pf[I_PRED_4x4_V] = x264_predict_4x4_v_aarch64; 38 | } 39 | 40 | if( cpu&X264_CPU_NEON ) 41 | { 42 | pf[I_PRED_4x4_DC] = x264_predict_4x4_dc_neon; 43 | pf[I_PRED_4x4_DC_TOP] = x264_predict_4x4_dc_top_neon; 44 | pf[I_PRED_4x4_DDL] = x264_predict_4x4_ddl_neon; 45 | pf[I_PRED_4x4_DDR] = x264_predict_4x4_ddr_neon; 46 | } 47 | #endif // !HIGH_BIT_DEPTH 48 | } 49 | 50 | void x264_predict_8x8c_init_aarch64( uint32_t cpu, x264_predict_t pf[7] ) 51 | { 52 | #if !HIGH_BIT_DEPTH 53 | if( cpu&X264_CPU_ARMV8 ) 54 | { 55 | pf[I_PRED_CHROMA_V] = x264_predict_8x8c_v_aarch64; 56 | } 57 | 58 | if( !(cpu&X264_CPU_NEON) ) 59 | return; 60 | 61 | pf[I_PRED_CHROMA_DC] = x264_predict_8x8c_dc_neon; 62 | pf[I_PRED_CHROMA_DC_TOP] = x264_predict_8x8c_dc_top_neon; 63 | pf[I_PRED_CHROMA_DC_LEFT] = x264_predict_8x8c_dc_left_neon; 64 | pf[I_PRED_CHROMA_H] = x264_predict_8x8c_h_neon; 65 | pf[I_PRED_CHROMA_P] = x264_predict_8x8c_p_neon; 66 | #endif // !HIGH_BIT_DEPTH 67 | } 68 | 69 | 70 | void x264_predict_8x16c_init_aarch64( uint32_t cpu, x264_predict_t pf[7] ) 71 | { 72 | if( !(cpu&X264_CPU_NEON) ) 73 | return; 74 | 75 | #if !HIGH_BIT_DEPTH 76 | pf[I_PRED_CHROMA_V ] = x264_predict_8x16c_v_neon; 77 | pf[I_PRED_CHROMA_H ] = x264_predict_8x16c_h_neon; 78 | pf[I_PRED_CHROMA_DC] = x264_predict_8x16c_dc_neon; 79 | pf[I_PRED_CHROMA_P ] = x264_predict_8x16c_p_neon; 80 | pf[I_PRED_CHROMA_DC_LEFT]= x264_predict_8x16c_dc_left_neon; 81 | pf[I_PRED_CHROMA_DC_TOP ]= x264_predict_8x16c_dc_top_neon; 82 | #endif // !HIGH_BIT_DEPTH 83 | } 84 | 85 | void x264_predict_8x8_init_aarch64( uint32_t cpu, x264_predict8x8_t pf[12], x264_predict_8x8_filter_t *predict_filter ) 86 | { 87 | if( !(cpu&X264_CPU_NEON) ) 88 | return; 89 | 90 | #if !HIGH_BIT_DEPTH 91 | pf[I_PRED_8x8_DDL] = x264_predict_8x8_ddl_neon; 92 | pf[I_PRED_8x8_DDR] = x264_predict_8x8_ddr_neon; 93 | pf[I_PRED_8x8_VL] = x264_predict_8x8_vl_neon; 94 | pf[I_PRED_8x8_VR] = x264_predict_8x8_vr_neon; 95 | pf[I_PRED_8x8_DC] = x264_predict_8x8_dc_neon; 96 | pf[I_PRED_8x8_H] = x264_predict_8x8_h_neon; 97 | pf[I_PRED_8x8_HD] = x264_predict_8x8_hd_neon; 98 | pf[I_PRED_8x8_HU] = x264_predict_8x8_hu_neon; 99 | pf[I_PRED_8x8_V] = x264_predict_8x8_v_neon; 100 | #endif // !HIGH_BIT_DEPTH 101 | } 102 | 103 | void x264_predict_16x16_init_aarch64( uint32_t cpu, x264_predict_t pf[7] ) 104 | { 105 | if( !(cpu&X264_CPU_NEON) ) 106 | return; 107 | 108 | #if !HIGH_BIT_DEPTH 109 | pf[I_PRED_16x16_DC ] = x264_predict_16x16_dc_neon; 110 | pf[I_PRED_16x16_DC_TOP] = x264_predict_16x16_dc_top_neon; 111 | pf[I_PRED_16x16_DC_LEFT]= x264_predict_16x16_dc_left_neon; 112 | pf[I_PRED_16x16_H ] = x264_predict_16x16_h_neon; 113 | pf[I_PRED_16x16_V ] = x264_predict_16x16_v_neon; 114 | pf[I_PRED_16x16_P ] = x264_predict_16x16_p_neon; 115 | #endif // !HIGH_BIT_DEPTH 116 | } 117 | -------------------------------------------------------------------------------- /x264c/external/x264/encoder/ratecontrol.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * ratecontrol.h: ratecontrol 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2022 x264 project 5 | * 6 | * Authors: Loren Merritt 7 | * Laurent Aimar 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 22 | * 23 | * This program is also available under a commercial proprietary license. 24 | * For more information, contact us at licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #ifndef X264_ENCODER_RATECONTROL_H 28 | #define X264_ENCODER_RATECONTROL_H 29 | 30 | /* Completely arbitrary. Ratecontrol lowers relative quality at higher framerates 31 | * and the reverse at lower framerates; this serves as the center of the curve. 32 | * Halve all the values for frame-packed 3D to compensate for the "doubled" 33 | * framerate. */ 34 | #define BASE_FRAME_DURATION (0.04f / ((h->param.i_frame_packing == 5)+1)) 35 | 36 | /* Arbitrary limitations as a sanity check. */ 37 | #define MAX_FRAME_DURATION (1.00f / ((h->param.i_frame_packing == 5)+1)) 38 | #define MIN_FRAME_DURATION (0.01f / ((h->param.i_frame_packing == 5)+1)) 39 | 40 | #define CLIP_DURATION(f) x264_clip3f(f,MIN_FRAME_DURATION,MAX_FRAME_DURATION) 41 | 42 | #define x264_ratecontrol_new x264_template(ratecontrol_new) 43 | int x264_ratecontrol_new ( x264_t * ); 44 | #define x264_ratecontrol_delete x264_template(ratecontrol_delete) 45 | void x264_ratecontrol_delete( x264_t * ); 46 | 47 | #define x264_ratecontrol_init_reconfigurable x264_template(ratecontrol_init_reconfigurable) 48 | void x264_ratecontrol_init_reconfigurable( x264_t *h, int b_init ); 49 | #define x264_encoder_reconfig_apply x264_template(encoder_reconfig_apply) 50 | int x264_encoder_reconfig_apply( x264_t *h, x264_param_t *param ); 51 | 52 | #define x264_adaptive_quant_frame x264_template(adaptive_quant_frame) 53 | void x264_adaptive_quant_frame( x264_t *h, x264_frame_t *frame, float *quant_offsets ); 54 | #define x264_macroblock_tree_read x264_template(macroblock_tree_read) 55 | int x264_macroblock_tree_read( x264_t *h, x264_frame_t *frame, float *quant_offsets ); 56 | #define x264_reference_build_list_optimal x264_template(reference_build_list_optimal) 57 | int x264_reference_build_list_optimal( x264_t *h ); 58 | #define x264_thread_sync_ratecontrol x264_template(thread_sync_ratecontrol) 59 | void x264_thread_sync_ratecontrol( x264_t *cur, x264_t *prev, x264_t *next ); 60 | #define x264_ratecontrol_zone_init x264_template(ratecontrol_zone_init) 61 | void x264_ratecontrol_zone_init( x264_t * ); 62 | #define x264_ratecontrol_start x264_template(ratecontrol_start) 63 | void x264_ratecontrol_start( x264_t *, int i_force_qp, int overhead ); 64 | #define x264_ratecontrol_slice_type x264_template(ratecontrol_slice_type) 65 | int x264_ratecontrol_slice_type( x264_t *, int i_frame ); 66 | #define x264_ratecontrol_set_weights x264_template(ratecontrol_set_weights) 67 | void x264_ratecontrol_set_weights( x264_t *h, x264_frame_t *frm ); 68 | #define x264_ratecontrol_mb x264_template(ratecontrol_mb) 69 | int x264_ratecontrol_mb( x264_t *, int bits ); 70 | #define x264_ratecontrol_qp x264_template(ratecontrol_qp) 71 | int x264_ratecontrol_qp( x264_t * ); 72 | #define x264_ratecontrol_mb_qp x264_template(ratecontrol_mb_qp) 73 | int x264_ratecontrol_mb_qp( x264_t *h ); 74 | #define x264_ratecontrol_end x264_template(ratecontrol_end) 75 | int x264_ratecontrol_end( x264_t *, int bits, int *filler ); 76 | #define x264_ratecontrol_summary x264_template(ratecontrol_summary) 77 | void x264_ratecontrol_summary( x264_t * ); 78 | #define x264_rc_analyse_slice x264_template(rc_analyse_slice) 79 | int x264_rc_analyse_slice( x264_t *h ); 80 | #define x264_threads_distribute_ratecontrol x264_template(threads_distribute_ratecontrol) 81 | void x264_threads_distribute_ratecontrol( x264_t *h ); 82 | #define x264_threads_merge_ratecontrol x264_template(threads_merge_ratecontrol) 83 | void x264_threads_merge_ratecontrol( x264_t *h ); 84 | #define x264_hrd_fullness x264_template(hrd_fullness) 85 | void x264_hrd_fullness( x264_t *h ); 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /x264c/external/x264/common/aarch64/cabac-a.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * cabac-a.S: aarch64 cabac 3 | ***************************************************************************** 4 | * Copyright (C) 2014-2022 x264 project 5 | * 6 | * Authors: Janne Grunau 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #include "asm.S" 27 | #include "asm-offsets.h" 28 | 29 | // w11 holds x264_cabac_t.i_low 30 | // w12 holds x264_cabac_t.i_range 31 | 32 | function cabac_encode_decision_asm, export=1 33 | add w10, w1, #CABAC_STATE 34 | ldrb w3, [x0, w10, uxtw] // i_state 35 | ldr w12, [x0, #CABAC_I_RANGE] 36 | movrel x8, X264(cabac_range_lps), -4 37 | movrel x9, X264(cabac_transition) 38 | ubfx x4, x3, #1, #7 39 | asr w5, w12, #6 40 | add x8, x8, x4, lsl #2 41 | orr w14, w2, w3, lsl #1 42 | ldrb w4, [x8, w5, uxtw] // i_range_lps 43 | ldr w11, [x0, #CABAC_I_LOW] 44 | eor w6, w2, w3 // b ^ i_state 45 | ldrb w9, [x9, w14, uxtw] 46 | sub w12, w12, w4 47 | add w7, w11, w12 48 | tst w6, #1 // (b ^ i_state) & 1 49 | csel w12, w4, w12, ne 50 | csel w11, w7, w11, ne 51 | strb w9, [x0, w10, uxtw] // i_state 52 | 53 | cabac_encode_renorm: 54 | ldr w2, [x0, #CABAC_I_QUEUE] 55 | clz w5, w12 56 | sub w5, w5, #23 57 | lsl w11, w11, w5 58 | lsl w12, w12, w5 59 | adds w2, w2, w5 60 | b.ge cabac_putbyte 61 | 62 | stp w11, w12, [x0, #CABAC_I_LOW] // store i_low, i_range 63 | str w2, [x0, #CABAC_I_QUEUE] 64 | ret 65 | 66 | .align 5 67 | cabac_putbyte: 68 | ldr w6, [x0, #CABAC_I_BYTES_OUTSTANDING] 69 | add w14, w2, #10 70 | mov w13, #-1 71 | sub w2, w2, #8 72 | asr w4, w11, w14 // out 73 | lsl w13, w13, w14 74 | subs w5, w4, #0xff 75 | bic w11, w11, w13 76 | cinc w6, w6, eq 77 | b.eq 0f 78 | 79 | 1: 80 | ldr x7, [x0, #CABAC_P] 81 | asr w5, w4, #8 // carry 82 | ldurb w8, [x7, #-1] 83 | add w8, w8, w5 84 | sub w5, w5, #1 85 | sturb w8, [x7, #-1] 86 | cbz w6, 3f 87 | 2: 88 | subs w6, w6, #1 89 | strb w5, [x7], #1 90 | b.gt 2b 91 | 3: 92 | strb w4, [x7], #1 93 | str x7, [x0, #CABAC_P] 94 | 0: 95 | stp w11, w12, [x0, #CABAC_I_LOW] // store i_low, i_range 96 | stp w2, w6, [x0, #CABAC_I_QUEUE] // store i_queue, i_bytes_outstanding 97 | ret 98 | endfunc 99 | 100 | function cabac_encode_bypass_asm, export=1, align=5 101 | ldr w12, [x0, #CABAC_I_RANGE] 102 | ldr w11, [x0, #CABAC_I_LOW] 103 | ldr w2, [x0, #CABAC_I_QUEUE] 104 | and w1, w1, w12 105 | add w11, w1, w11, lsl #1 106 | adds w2, w2, #1 107 | b.ge cabac_putbyte 108 | str w11, [x0, #CABAC_I_LOW] 109 | str w2, [x0, #CABAC_I_QUEUE] 110 | ret 111 | endfunc 112 | 113 | function cabac_encode_terminal_asm, export=1, align=5 114 | ldr w12, [x0, #CABAC_I_RANGE] 115 | sub w12, w12, #2 116 | tbz w12, #8, 1f 117 | 118 | str w12, [x0, #CABAC_I_RANGE] 119 | ret 120 | 1: 121 | ldr w2, [x0, #CABAC_I_QUEUE] 122 | ldr w11, [x0, #CABAC_I_LOW] 123 | lsl w12, w12, #1 124 | adds w2, w2, #1 125 | lsl w11, w11, #1 126 | b.ge cabac_putbyte 127 | 128 | stp w11, w12, [x0, #CABAC_I_LOW] // store i_low, i_range 129 | str w2, [x0, #CABAC_I_QUEUE] 130 | ret 131 | endfunc 132 | -------------------------------------------------------------------------------- /x264c/external/x264/common/x86/bitstream.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * bitstream.h: x86 bitstream functions 3 | ***************************************************************************** 4 | * Copyright (C) 2017-2022 x264 project 5 | * 6 | * Authors: Anton Mitrofanov 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #ifndef X264_X86_BITSTREAM_H 27 | #define X264_X86_BITSTREAM_H 28 | 29 | #define x264_nal_escape_mmx2 x264_template(nal_escape_mmx2) 30 | uint8_t *x264_nal_escape_mmx2( uint8_t *dst, uint8_t *src, uint8_t *end ); 31 | #define x264_nal_escape_sse2 x264_template(nal_escape_sse2) 32 | uint8_t *x264_nal_escape_sse2( uint8_t *dst, uint8_t *src, uint8_t *end ); 33 | #define x264_nal_escape_avx2 x264_template(nal_escape_avx2) 34 | uint8_t *x264_nal_escape_avx2( uint8_t *dst, uint8_t *src, uint8_t *end ); 35 | #define x264_cabac_block_residual_rd_internal_sse2 x264_template(cabac_block_residual_rd_internal_sse2) 36 | void x264_cabac_block_residual_rd_internal_sse2 ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb ); 37 | #define x264_cabac_block_residual_rd_internal_lzcnt x264_template(cabac_block_residual_rd_internal_lzcnt) 38 | void x264_cabac_block_residual_rd_internal_lzcnt ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb ); 39 | #define x264_cabac_block_residual_rd_internal_ssse3 x264_template(cabac_block_residual_rd_internal_ssse3) 40 | void x264_cabac_block_residual_rd_internal_ssse3 ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb ); 41 | #define x264_cabac_block_residual_rd_internal_ssse3_lzcnt x264_template(cabac_block_residual_rd_internal_ssse3_lzcnt) 42 | void x264_cabac_block_residual_rd_internal_ssse3_lzcnt( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb ); 43 | #define x264_cabac_block_residual_rd_internal_avx512 x264_template(cabac_block_residual_rd_internal_avx512) 44 | void x264_cabac_block_residual_rd_internal_avx512 ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb ); 45 | #define x264_cabac_block_residual_8x8_rd_internal_sse2 x264_template(cabac_block_residual_8x8_rd_internal_sse2) 46 | void x264_cabac_block_residual_8x8_rd_internal_sse2 ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb ); 47 | #define x264_cabac_block_residual_8x8_rd_internal_lzcnt x264_template(cabac_block_residual_8x8_rd_internal_lzcnt) 48 | void x264_cabac_block_residual_8x8_rd_internal_lzcnt ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb ); 49 | #define x264_cabac_block_residual_8x8_rd_internal_ssse3 x264_template(cabac_block_residual_8x8_rd_internal_ssse3) 50 | void x264_cabac_block_residual_8x8_rd_internal_ssse3 ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb ); 51 | #define x264_cabac_block_residual_8x8_rd_internal_ssse3_lzcnt x264_template(cabac_block_residual_8x8_rd_internal_ssse3_lzcnt) 52 | void x264_cabac_block_residual_8x8_rd_internal_ssse3_lzcnt( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb ); 53 | #define x264_cabac_block_residual_8x8_rd_internal_avx512 x264_template(cabac_block_residual_8x8_rd_internal_avx512) 54 | void x264_cabac_block_residual_8x8_rd_internal_avx512 ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb ); 55 | #define x264_cabac_block_residual_internal_sse2 x264_template(cabac_block_residual_internal_sse2) 56 | void x264_cabac_block_residual_internal_sse2 ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb ); 57 | #define x264_cabac_block_residual_internal_lzcnt x264_template(cabac_block_residual_internal_lzcnt) 58 | void x264_cabac_block_residual_internal_lzcnt ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb ); 59 | #define x264_cabac_block_residual_internal_avx2 x264_template(cabac_block_residual_internal_avx2) 60 | void x264_cabac_block_residual_internal_avx2 ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb ); 61 | #define x264_cabac_block_residual_internal_avx512 x264_template(cabac_block_residual_internal_avx512) 62 | void x264_cabac_block_residual_internal_avx512( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb ); 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /x264c/external/x264/common/aarch64/dct.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * dct.h: aarch64 transform and zigzag 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2022 x264 project 5 | * 6 | * Authors: David Conrad 7 | * Janne Grunau 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 22 | * 23 | * This program is also available under a commercial proprietary license. 24 | * For more information, contact us at licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #ifndef X264_AARCH64_DCT_H 28 | #define X264_AARCH64_DCT_H 29 | 30 | #define x264_dct4x4dc_neon x264_template(dct4x4dc_neon) 31 | void x264_dct4x4dc_neon( int16_t d[16] ); 32 | #define x264_idct4x4dc_neon x264_template(idct4x4dc_neon) 33 | void x264_idct4x4dc_neon( int16_t d[16] ); 34 | 35 | #define x264_sub4x4_dct_neon x264_template(sub4x4_dct_neon) 36 | void x264_sub4x4_dct_neon( int16_t dct[16], uint8_t *pix1, uint8_t *pix2 ); 37 | #define x264_sub8x8_dct_neon x264_template(sub8x8_dct_neon) 38 | void x264_sub8x8_dct_neon( int16_t dct[4][16], uint8_t *pix1, uint8_t *pix2 ); 39 | #define x264_sub16x16_dct_neon x264_template(sub16x16_dct_neon) 40 | void x264_sub16x16_dct_neon( int16_t dct[16][16], uint8_t *pix1, uint8_t *pix2 ); 41 | 42 | #define x264_add4x4_idct_neon x264_template(add4x4_idct_neon) 43 | void x264_add4x4_idct_neon( uint8_t *p_dst, int16_t dct[16] ); 44 | #define x264_add8x8_idct_neon x264_template(add8x8_idct_neon) 45 | void x264_add8x8_idct_neon( uint8_t *p_dst, int16_t dct[4][16] ); 46 | #define x264_add16x16_idct_neon x264_template(add16x16_idct_neon) 47 | void x264_add16x16_idct_neon( uint8_t *p_dst, int16_t dct[16][16] ); 48 | 49 | #define x264_add8x8_idct_dc_neon x264_template(add8x8_idct_dc_neon) 50 | void x264_add8x8_idct_dc_neon( uint8_t *p_dst, int16_t dct[4] ); 51 | #define x264_add16x16_idct_dc_neon x264_template(add16x16_idct_dc_neon) 52 | void x264_add16x16_idct_dc_neon( uint8_t *p_dst, int16_t dct[16] ); 53 | #define x264_sub8x8_dct_dc_neon x264_template(sub8x8_dct_dc_neon) 54 | void x264_sub8x8_dct_dc_neon( int16_t dct[4], uint8_t *pix1, uint8_t *pix2 ); 55 | #define x264_sub8x16_dct_dc_neon x264_template(sub8x16_dct_dc_neon) 56 | void x264_sub8x16_dct_dc_neon( int16_t dct[8], uint8_t *pix1, uint8_t *pix2 ); 57 | 58 | #define x264_sub8x8_dct8_neon x264_template(sub8x8_dct8_neon) 59 | void x264_sub8x8_dct8_neon( int16_t dct[64], uint8_t *pix1, uint8_t *pix2 ); 60 | #define x264_sub16x16_dct8_neon x264_template(sub16x16_dct8_neon) 61 | void x264_sub16x16_dct8_neon( int16_t dct[4][64], uint8_t *pix1, uint8_t *pix2 ); 62 | 63 | #define x264_add8x8_idct8_neon x264_template(add8x8_idct8_neon) 64 | void x264_add8x8_idct8_neon( uint8_t *p_dst, int16_t dct[64] ); 65 | #define x264_add16x16_idct8_neon x264_template(add16x16_idct8_neon) 66 | void x264_add16x16_idct8_neon( uint8_t *p_dst, int16_t dct[4][64] ); 67 | 68 | #define x264_zigzag_scan_4x4_frame_neon x264_template(zigzag_scan_4x4_frame_neon) 69 | void x264_zigzag_scan_4x4_frame_neon( int16_t level[16], int16_t dct[16] ); 70 | #define x264_zigzag_scan_4x4_field_neon x264_template(zigzag_scan_4x4_field_neon) 71 | void x264_zigzag_scan_4x4_field_neon( int16_t level[16], int16_t dct[16] ); 72 | #define x264_zigzag_scan_8x8_frame_neon x264_template(zigzag_scan_8x8_frame_neon) 73 | void x264_zigzag_scan_8x8_frame_neon( int16_t level[64], int16_t dct[64] ); 74 | #define x264_zigzag_scan_8x8_field_neon x264_template(zigzag_scan_8x8_field_neon) 75 | void x264_zigzag_scan_8x8_field_neon( int16_t level[64], int16_t dct[64] ); 76 | 77 | #define x264_zigzag_sub_4x4_field_neon x264_template(zigzag_sub_4x4_field_neon) 78 | int x264_zigzag_sub_4x4_field_neon( dctcoef level[16], const pixel *p_src, pixel *p_dst ); 79 | #define x264_zigzag_sub_4x4ac_field_neon x264_template(zigzag_sub_4x4ac_field_neon) 80 | int x264_zigzag_sub_4x4ac_field_neon( dctcoef level[16], const pixel *p_src, pixel *p_dst, dctcoef *dc ); 81 | #define x264_zigzag_sub_4x4_frame_neon x264_template(zigzag_sub_4x4_frame_neon) 82 | int x264_zigzag_sub_4x4_frame_neon( dctcoef level[16], const pixel *p_src, pixel *p_dst ); 83 | #define x264_zigzag_sub_4x4ac_frame_neon x264_template(zigzag_sub_4x4ac_frame_neon) 84 | int x264_zigzag_sub_4x4ac_frame_neon( dctcoef level[16], const pixel *p_src, pixel *p_dst, dctcoef *dc ); 85 | 86 | #define x264_zigzag_sub_8x8_field_neon x264_template(zigzag_sub_8x8_field_neon) 87 | int x264_zigzag_sub_8x8_field_neon( dctcoef level[16], const pixel *p_src, pixel *p_dst ); 88 | #define x264_zigzag_sub_8x8_frame_neon x264_template(zigzag_sub_8x8_frame_neon) 89 | int x264_zigzag_sub_8x8_frame_neon( dctcoef level[16], const pixel *p_src, pixel *p_dst ); 90 | 91 | #define x264_zigzag_interleave_8x8_cavlc_neon x264_template(zigzag_interleave_8x8_cavlc_neon) 92 | void x264_zigzag_interleave_8x8_cavlc_neon( dctcoef *dst, dctcoef *src, uint8_t *nnz ); 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /x264c/external/x264/common/set.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * set.h: quantization init 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2022 x264 project 5 | * 6 | * Authors: Loren Merritt 7 | * Laurent Aimar 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 22 | * 23 | * This program is also available under a commercial proprietary license. 24 | * For more information, contact us at licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #ifndef X264_SET_H 28 | #define X264_SET_H 29 | 30 | enum cqm4_e 31 | { 32 | CQM_4IY = 0, 33 | CQM_4PY = 1, 34 | CQM_4IC = 2, 35 | CQM_4PC = 3 36 | }; 37 | enum cqm8_e 38 | { 39 | CQM_8IY = 0, 40 | CQM_8PY = 1, 41 | CQM_8IC = 2, 42 | CQM_8PC = 3, 43 | }; 44 | 45 | typedef struct 46 | { 47 | int i_id; 48 | 49 | int i_profile_idc; 50 | int i_level_idc; 51 | 52 | int b_constraint_set0; 53 | int b_constraint_set1; 54 | int b_constraint_set2; 55 | int b_constraint_set3; 56 | 57 | int i_log2_max_frame_num; 58 | 59 | int i_poc_type; 60 | /* poc 0 */ 61 | int i_log2_max_poc_lsb; 62 | 63 | int i_num_ref_frames; 64 | int b_gaps_in_frame_num_value_allowed; 65 | int i_mb_width; 66 | int i_mb_height; 67 | int b_frame_mbs_only; 68 | int b_mb_adaptive_frame_field; 69 | int b_direct8x8_inference; 70 | 71 | int b_crop; 72 | struct 73 | { 74 | int i_left; 75 | int i_right; 76 | int i_top; 77 | int i_bottom; 78 | } crop; 79 | 80 | int b_vui; 81 | struct 82 | { 83 | int b_aspect_ratio_info_present; 84 | int i_sar_width; 85 | int i_sar_height; 86 | 87 | int b_overscan_info_present; 88 | int b_overscan_info; 89 | 90 | int b_signal_type_present; 91 | int i_vidformat; 92 | int b_fullrange; 93 | int b_color_description_present; 94 | int i_colorprim; 95 | int i_transfer; 96 | int i_colmatrix; 97 | 98 | int b_chroma_loc_info_present; 99 | int i_chroma_loc_top; 100 | int i_chroma_loc_bottom; 101 | 102 | int b_timing_info_present; 103 | uint32_t i_num_units_in_tick; 104 | uint32_t i_time_scale; 105 | int b_fixed_frame_rate; 106 | 107 | int b_nal_hrd_parameters_present; 108 | int b_vcl_hrd_parameters_present; 109 | 110 | struct 111 | { 112 | int i_cpb_cnt; 113 | int i_bit_rate_scale; 114 | int i_cpb_size_scale; 115 | int i_bit_rate_value; 116 | int i_cpb_size_value; 117 | int i_bit_rate_unscaled; 118 | int i_cpb_size_unscaled; 119 | int b_cbr_hrd; 120 | 121 | int i_initial_cpb_removal_delay_length; 122 | int i_cpb_removal_delay_length; 123 | int i_dpb_output_delay_length; 124 | int i_time_offset_length; 125 | } hrd; 126 | 127 | int b_pic_struct_present; 128 | int b_bitstream_restriction; 129 | int b_motion_vectors_over_pic_boundaries; 130 | int i_max_bytes_per_pic_denom; 131 | int i_max_bits_per_mb_denom; 132 | int i_log2_max_mv_length_horizontal; 133 | int i_log2_max_mv_length_vertical; 134 | int i_num_reorder_frames; 135 | int i_max_dec_frame_buffering; 136 | 137 | /* FIXME to complete */ 138 | } vui; 139 | 140 | int b_qpprime_y_zero_transform_bypass; 141 | int i_chroma_format_idc; 142 | 143 | int b_avcintra_hd; 144 | int b_avcintra_4k; 145 | int i_cqm_preset; 146 | const uint8_t *scaling_list[8]; /* could be 12, but we don't allow separate Cb/Cr lists */ 147 | 148 | } x264_sps_t; 149 | 150 | typedef struct 151 | { 152 | int i_id; 153 | int i_sps_id; 154 | 155 | int b_cabac; 156 | 157 | int b_pic_order; 158 | int i_num_slice_groups; 159 | 160 | int i_num_ref_idx_l0_default_active; 161 | int i_num_ref_idx_l1_default_active; 162 | 163 | int b_weighted_pred; 164 | int b_weighted_bipred; 165 | 166 | int i_pic_init_qp; 167 | int i_pic_init_qs; 168 | 169 | int i_chroma_qp_index_offset; 170 | 171 | int b_deblocking_filter_control; 172 | int b_constrained_intra_pred; 173 | int b_redundant_pic_cnt; 174 | 175 | int b_transform_8x8_mode; 176 | 177 | } x264_pps_t; 178 | 179 | #define x264_cqm_init x264_template(cqm_init) 180 | int x264_cqm_init( x264_t *h ); 181 | #define x264_cqm_delete x264_template(cqm_delete) 182 | void x264_cqm_delete( x264_t *h ); 183 | #define x264_cqm_parse_file x264_template(cqm_parse_file) 184 | int x264_cqm_parse_file( x264_t *h, const char *filename ); 185 | 186 | #endif 187 | -------------------------------------------------------------------------------- /x264c/external/x264/common/cabac.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * cabac.h: arithmetic coder 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2022 x264 project 5 | * 6 | * Authors: Loren Merritt 7 | * Laurent Aimar 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 22 | * 23 | * This program is also available under a commercial proprietary license. 24 | * For more information, contact us at licensing@x264.com. 25 | *****************************************************************************/ 26 | 27 | #ifndef X264_CABAC_H 28 | #define X264_CABAC_H 29 | 30 | typedef struct 31 | { 32 | /* state */ 33 | int i_low; 34 | int i_range; 35 | 36 | /* bit stream */ 37 | int i_queue; //stored with an offset of -8 for faster asm 38 | int i_bytes_outstanding; 39 | 40 | uint8_t *p_start; 41 | uint8_t *p; 42 | uint8_t *p_end; 43 | 44 | /* aligned for memcpy_aligned starting here */ 45 | ALIGNED_64( int f8_bits_encoded ); // only if using x264_cabac_size_decision() 46 | 47 | /* context */ 48 | uint8_t state[1024]; 49 | 50 | /* for 16-byte alignment */ 51 | uint8_t padding[12]; 52 | } x264_cabac_t; 53 | 54 | /* init the contexts given i_slice_type, the quantif and the model */ 55 | #define x264_cabac_context_init x264_template(cabac_context_init) 56 | void x264_cabac_context_init( x264_t *h, x264_cabac_t *cb, int i_slice_type, int i_qp, int i_model ); 57 | 58 | #define x264_cabac_encode_init_core x264_template(cabac_encode_init_core) 59 | void x264_cabac_encode_init_core( x264_cabac_t *cb ); 60 | #define x264_cabac_encode_init x264_template(cabac_encode_init) 61 | void x264_cabac_encode_init( x264_cabac_t *cb, uint8_t *p_data, uint8_t *p_end ); 62 | #define x264_cabac_encode_decision_c x264_template(cabac_encode_decision_c) 63 | void x264_cabac_encode_decision_c( x264_cabac_t *cb, int i_ctx, int b ); 64 | #define x264_cabac_encode_decision_asm x264_template(cabac_encode_decision_asm) 65 | void x264_cabac_encode_decision_asm( x264_cabac_t *cb, int i_ctx, int b ); 66 | #define x264_cabac_encode_bypass_c x264_template(cabac_encode_bypass_c) 67 | void x264_cabac_encode_bypass_c( x264_cabac_t *cb, int b ); 68 | #define x264_cabac_encode_bypass_asm x264_template(cabac_encode_bypass_asm) 69 | void x264_cabac_encode_bypass_asm( x264_cabac_t *cb, int b ); 70 | #define x264_cabac_encode_terminal_c x264_template(cabac_encode_terminal_c) 71 | void x264_cabac_encode_terminal_c( x264_cabac_t *cb ); 72 | #define x264_cabac_encode_terminal_asm x264_template(cabac_encode_terminal_asm) 73 | void x264_cabac_encode_terminal_asm( x264_cabac_t *cb ); 74 | #define x264_cabac_encode_ue_bypass x264_template(cabac_encode_ue_bypass) 75 | void x264_cabac_encode_ue_bypass( x264_cabac_t *cb, int exp_bits, int val ); 76 | #define x264_cabac_encode_flush x264_template(cabac_encode_flush) 77 | void x264_cabac_encode_flush( x264_t *h, x264_cabac_t *cb ); 78 | 79 | #if HAVE_MMX 80 | #define x264_cabac_encode_decision x264_cabac_encode_decision_asm 81 | #define x264_cabac_encode_bypass x264_cabac_encode_bypass_asm 82 | #define x264_cabac_encode_terminal x264_cabac_encode_terminal_asm 83 | #elif HAVE_AARCH64 84 | #define x264_cabac_encode_decision x264_cabac_encode_decision_asm 85 | #define x264_cabac_encode_bypass x264_cabac_encode_bypass_asm 86 | #define x264_cabac_encode_terminal x264_cabac_encode_terminal_asm 87 | #else 88 | #define x264_cabac_encode_decision x264_cabac_encode_decision_c 89 | #define x264_cabac_encode_bypass x264_cabac_encode_bypass_c 90 | #define x264_cabac_encode_terminal x264_cabac_encode_terminal_c 91 | #endif 92 | #define x264_cabac_encode_decision_noup x264_cabac_encode_decision 93 | 94 | static ALWAYS_INLINE int x264_cabac_pos( x264_cabac_t *cb ) 95 | { 96 | return (cb->p - cb->p_start + cb->i_bytes_outstanding) * 8 + cb->i_queue; 97 | } 98 | 99 | /* internal only. these don't write the bitstream, just calculate bit cost: */ 100 | 101 | static ALWAYS_INLINE void x264_cabac_size_decision( x264_cabac_t *cb, long i_ctx, long b ) 102 | { 103 | int i_state = cb->state[i_ctx]; 104 | cb->state[i_ctx] = x264_cabac_transition[i_state][b]; 105 | cb->f8_bits_encoded += x264_cabac_entropy[i_state^b]; 106 | } 107 | 108 | static ALWAYS_INLINE int x264_cabac_size_decision2( uint8_t *state, long b ) 109 | { 110 | int i_state = *state; 111 | *state = x264_cabac_transition[i_state][b]; 112 | return x264_cabac_entropy[i_state^b]; 113 | } 114 | 115 | static ALWAYS_INLINE void x264_cabac_size_decision_noup( x264_cabac_t *cb, long i_ctx, long b ) 116 | { 117 | int i_state = cb->state[i_ctx]; 118 | cb->f8_bits_encoded += x264_cabac_entropy[i_state^b]; 119 | } 120 | 121 | static ALWAYS_INLINE int x264_cabac_size_decision_noup2( uint8_t *state, long b ) 122 | { 123 | return x264_cabac_entropy[*state^b]; 124 | } 125 | 126 | #endif 127 | -------------------------------------------------------------------------------- /x264c/external/x264/common/opencl/downscale.cl: -------------------------------------------------------------------------------- 1 | /* 2 | * downscale lowres luma: full-res buffer to down scale image, and to packed hpel image 3 | * 4 | * -- 5 | * 6 | * fenc_img is an output image (area of memory referenced through a texture 7 | * cache). A read of any pixel location (x,y) returns four pixel values: 8 | * 9 | * val.s0 = P(x,y) 10 | * val.s1 = P(x+1,y) 11 | * val.s2 = P(x+2,y) 12 | * val.s3 = P(x+3,y) 13 | * 14 | * This is a 4x replication of the lowres pixels, a trade-off between memory 15 | * size and read latency. 16 | * 17 | * -- 18 | * 19 | * hpel_planes is an output image that contains the four HPEL planes used for 20 | * subpel refinement. A read of any pixel location (x,y) returns a UInt32 with 21 | * the four planar values C | V | H | F 22 | * 23 | * launch dimensions: [lowres-width, lowres-height] 24 | */ 25 | kernel void downscale_hpel( const global pixel *fenc, 26 | write_only image2d_t fenc_img, 27 | write_only image2d_t hpel_planes, 28 | int stride ) 29 | { 30 | int x = get_global_id( 0 ); 31 | int y = get_global_id( 1 ); 32 | uint4 values; 33 | 34 | fenc += y * stride * 2; 35 | const global pixel *src1 = fenc + stride; 36 | const global pixel *src2 = (y == get_global_size( 1 )-1) ? src1 : src1 + stride; 37 | int2 pos = (int2)(x, y); 38 | pixel right, left; 39 | 40 | right = rhadd( fenc[x*2], src1[x*2] ); 41 | left = rhadd( fenc[x*2+1], src1[x*2+1] ); 42 | values.s0 = rhadd( right, left ); // F 43 | 44 | right = rhadd( fenc[2*x+1], src1[2*x+1] ); 45 | left = rhadd( fenc[2*x+2], src1[2*x+2] ); 46 | values.s1 = rhadd( right, left ); // H 47 | 48 | right = rhadd( src1[2*x], src2[2*x] ); 49 | left = rhadd( src1[2*x+1], src2[2*x+1] ); 50 | values.s2 = rhadd( right, left ); // V 51 | 52 | right = rhadd( src1[2*x+1], src2[2*x+1] ); 53 | left = rhadd( src1[2*x+2], src2[2*x+2] ); 54 | values.s3 = rhadd( right, left ); // C 55 | 56 | uint4 val = (uint4) ((values.s3 & 0xff) << 24) | ((values.s2 & 0xff) << 16) | ((values.s1 & 0xff) << 8) | (values.s0 & 0xff); 57 | write_imageui( hpel_planes, pos, val ); 58 | 59 | x = select( x, x+1, x+1 < get_global_size( 0 ) ); 60 | right = rhadd( fenc[x*2], src1[x*2] ); 61 | left = rhadd( fenc[x*2+1], src1[x*2+1] ); 62 | values.s1 = rhadd( right, left ); 63 | 64 | x = select( x, x+1, x+1 < get_global_size( 0 ) ); 65 | right = rhadd( fenc[x*2], src1[x*2] ); 66 | left = rhadd( fenc[x*2+1], src1[x*2+1] ); 67 | values.s2 = rhadd( right, left ); 68 | 69 | x = select( x, x+1, x+1 < get_global_size( 0 ) ); 70 | right = rhadd( fenc[x*2], src1[x*2] ); 71 | left = rhadd( fenc[x*2+1], src1[x*2+1] ); 72 | values.s3 = rhadd( right, left ); 73 | 74 | write_imageui( fenc_img, pos, values ); 75 | } 76 | 77 | /* 78 | * downscale lowres hierarchical motion search image, copy from one image to 79 | * another decimated image. This kernel is called iteratively to generate all 80 | * of the downscales. 81 | * 82 | * launch dimensions: [lower_res width, lower_res height] 83 | */ 84 | kernel void downscale1( read_only image2d_t higher_res, write_only image2d_t lower_res ) 85 | { 86 | int x = get_global_id( 0 ); 87 | int y = get_global_id( 1 ); 88 | int2 pos = (int2)(x, y); 89 | int gs = get_global_size( 0 ); 90 | uint4 top, bot, values; 91 | top = read_imageui( higher_res, sampler, (int2)(x*2, 2*y) ); 92 | bot = read_imageui( higher_res, sampler, (int2)(x*2, 2*y+1) ); 93 | values.s0 = rhadd( rhadd( top.s0, bot.s0 ), rhadd( top.s1, bot.s1 ) ); 94 | 95 | /* these select statements appear redundant, and they should be, but tests break when 96 | * they are not here. I believe this was caused by a driver bug 97 | */ 98 | values.s1 = select( values.s0, rhadd( rhadd( top.s2, bot.s2 ), rhadd( top.s3, bot.s3 ) ), ( x + 1 < gs) ); 99 | top = read_imageui( higher_res, sampler, (int2)(x*2+4, 2*y) ); 100 | bot = read_imageui( higher_res, sampler, (int2)(x*2+4, 2*y+1) ); 101 | values.s2 = select( values.s1, rhadd( rhadd( top.s0, bot.s0 ), rhadd( top.s1, bot.s1 ) ), ( x + 2 < gs ) ); 102 | values.s3 = select( values.s2, rhadd( rhadd( top.s2, bot.s2 ), rhadd( top.s3, bot.s3 ) ), ( x + 3 < gs ) ); 103 | write_imageui( lower_res, pos, (uint4)(values) ); 104 | } 105 | 106 | /* 107 | * Second copy of downscale kernel, no differences. This is a (no perf loss) 108 | * workaround for a scheduling bug in current Tahiti drivers. This bug has 109 | * theoretically been fixed in the July 2012 driver release from AMD. 110 | */ 111 | kernel void downscale2( read_only image2d_t higher_res, write_only image2d_t lower_res ) 112 | { 113 | int x = get_global_id( 0 ); 114 | int y = get_global_id( 1 ); 115 | int2 pos = (int2)(x, y); 116 | int gs = get_global_size( 0 ); 117 | uint4 top, bot, values; 118 | top = read_imageui( higher_res, sampler, (int2)(x*2, 2*y) ); 119 | bot = read_imageui( higher_res, sampler, (int2)(x*2, 2*y+1) ); 120 | values.s0 = rhadd( rhadd( top.s0, bot.s0 ), rhadd( top.s1, bot.s1 ) ); 121 | 122 | // see comment in above function copy 123 | values.s1 = select( values.s0, rhadd( rhadd( top.s2, bot.s2 ), rhadd( top.s3, bot.s3 ) ), ( x + 1 < gs) ); 124 | top = read_imageui( higher_res, sampler, (int2)(x*2+4, 2*y) ); 125 | bot = read_imageui( higher_res, sampler, (int2)(x*2+4, 2*y+1) ); 126 | values.s2 = select( values.s1, rhadd( rhadd( top.s0, bot.s0 ), rhadd( top.s1, bot.s1 ) ), ( x + 2 < gs ) ); 127 | values.s3 = select( values.s2, rhadd( rhadd( top.s2, bot.s2 ), rhadd( top.s3, bot.s3 ) ), ( x + 3 < gs ) ); 128 | write_imageui( lower_res, pos, (uint4)(values) ); 129 | } 130 | 131 | /* OpenCL 1.2 finally added a memset command, but we're not targeting 1.2 */ 132 | kernel void memset_int16( global int16_t *buf, int16_t value ) 133 | { 134 | buf[get_global_id( 0 )] = value; 135 | } 136 | --------------------------------------------------------------------------------