]> granicus.if.org Git - libx264/commitdiff
Unify 8-bit and 10-bit CLI and libraries
authorVittorio Giovara <vittorio.giovara@gmail.com>
Fri, 6 Jan 2017 14:23:38 +0000 (15:23 +0100)
committerAnton Mitrofanov <BugMaster@narod.ru>
Sun, 24 Dec 2017 20:47:24 +0000 (23:47 +0300)
Add 'i_bitdepth' to x264_param_t with the corresponding '--output-depth' CLI
option to set the bit depth at runtime.

Drop the 'x264_bit_depth' global variable. Rather than hardcoding it to an
incorrect value, it's preferable to induce a linking failure. If applications
relies on this symbol this will make it more obvious where the problem is.

Add Makefile rules that compiles modules with different bit depths. Assembly
on x86 is prefixed with the 'private_prefix' define, while all other archs
modify their function prefix internally.

Templatize the main C library, x86/x86_64 assembly, ARM assembly, AARCH64
assembly, PowerPC assembly, and MIPS assembly.

The depth and cache CLI filters heavily depend on bit depth size, so they
need to be duplicated for each value. This means having to rename these
filters, and adjust the callers to use the right version.

Unfortunately the threaded input CLI module inherits a common.h dependency
(input/frame -> common/threadpool -> common/frame -> common/common) which
is extremely complicated to address in a sensible way. Instead duplicate
the module and select the appropriate one at run time.

Each bitdepth needs different checkasm compilation rules, so split the main
checkasm target into two executables.

129 files changed:
Makefile
common/aarch64/asm.S
common/aarch64/bitstream.h [new file with mode: 0644]
common/aarch64/cabac-a.S
common/aarch64/dct.h
common/aarch64/deblock.h [new file with mode: 0644]
common/aarch64/mc-c.c
common/aarch64/mc.h
common/aarch64/pixel.h
common/aarch64/predict-c.c
common/aarch64/predict.h
common/aarch64/quant-a.S
common/aarch64/quant.h
common/arm/asm.S
common/arm/bitstream.h [new file with mode: 0644]
common/arm/dct.h
common/arm/deblock.h [new file with mode: 0644]
common/arm/mc-c.c
common/arm/mc.h
common/arm/pixel.h
common/arm/predict.h
common/arm/quant-a.S
common/arm/quant.h
common/base.c [new file with mode: 0644]
common/base.h [new file with mode: 0644]
common/bitstream.c
common/bitstream.h
common/cabac.c
common/cabac.h
common/common.c
common/common.h
common/cpu.c
common/dct.c
common/dct.h
common/deblock.c
common/frame.h
common/macroblock.h
common/mc.c
common/mc.h
common/mips/dct-c.c
common/mips/dct.h
common/mips/deblock-c.c
common/mips/deblock.h [new file with mode: 0644]
common/mips/mc.h
common/mips/pixel.h
common/mips/predict-c.c
common/mips/predict.h
common/mips/quant-c.c
common/mips/quant.h
common/opencl.h
common/osdep.c
common/osdep.h
common/pixel.h
common/ppc/dct.c
common/ppc/dct.h
common/ppc/deblock.c
common/ppc/deblock.h [new file with mode: 0644]
common/ppc/mc.c
common/ppc/mc.h
common/ppc/pixel.c
common/ppc/pixel.h
common/ppc/predict.c
common/ppc/predict.h
common/ppc/quant.h
common/predict.h
common/quant.c
common/quant.h
common/rectangle.h
common/set.h
common/tables.c [new file with mode: 0644]
common/tables.h [new file with mode: 0644]
common/threadpool.h
common/vlc.c
common/win32thread.c
common/x86/bitstream.h [new file with mode: 0644]
common/x86/cabac-a.asm
common/x86/dct.h
common/x86/deblock.h [new file with mode: 0644]
common/x86/mc-c.c
common/x86/mc.h
common/x86/pixel-32.asm
common/x86/pixel-a.asm
common/x86/pixel.h
common/x86/predict.h
common/x86/quant-a.asm
common/x86/quant.h
common/x86/trellis-64.asm
common/x86/x86util.asm
configure
encoder/analyse.c
encoder/analyse.h
encoder/api.c [new file with mode: 0644]
encoder/cabac.c
encoder/encoder.c
encoder/macroblock.h
encoder/me.c
encoder/me.h
encoder/ratecontrol.h
encoder/rdo.c
encoder/set.c
encoder/set.h
encoder/slicetype-cl.c
encoder/slicetype-cl.h [new file with mode: 0644]
encoder/slicetype.c
example.c
filters/filters.c
filters/video/cache.c
filters/video/crop.c
filters/video/depth.c
filters/video/internal.c
filters/video/internal.h
filters/video/resize.c
filters/video/select_every.c
filters/video/video.c
input/avs.c
input/ffms.c
input/input.h
input/lavf.c
input/raw.c
input/thread.c
input/timecode.c
input/y4m.c
tools/checkasm-aarch64.S
tools/checkasm-arm.S
tools/checkasm.c
x264.c
x264.h
x264cli.h
x264dll.c

index 81bce652a6f35787b68cc0c0f07e6e61582a4ccd..8ec14057baa657311cfb64653086a18d3fecd9c4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -13,30 +13,43 @@ GENERATED =
 all: default
 default:
 
-SRCS = common/mc.c common/predict.c common/pixel.c common/macroblock.c \
-       common/frame.c common/dct.c common/cpu.c common/cabac.c \
-       common/common.c common/osdep.c common/rectangle.c \
-       common/set.c common/quant.c common/deblock.c common/vlc.c \
-       common/mvpred.c common/bitstream.c \
-       encoder/analyse.c encoder/me.c encoder/ratecontrol.c \
-       encoder/set.c encoder/macroblock.c encoder/cabac.c \
-       encoder/cavlc.c encoder/encoder.c encoder/lookahead.c
+SRCS = common/osdep.c common/base.c common/cpu.c common/tables.c \
+       encoder/api.c
+
+SRCS_X = common/mc.c common/predict.c common/pixel.c common/macroblock.c \
+         common/frame.c common/dct.c common/cabac.c \
+         common/common.c common/rectangle.c \
+         common/set.c common/quant.c common/deblock.c common/vlc.c \
+         common/mvpred.c common/bitstream.c \
+         encoder/analyse.c encoder/me.c encoder/ratecontrol.c \
+         encoder/set.c encoder/macroblock.c encoder/cabac.c \
+         encoder/cavlc.c encoder/encoder.c encoder/lookahead.c
+
+SRCS_8 =
 
 SRCCLI = x264.c input/input.c input/timecode.c input/raw.c input/y4m.c \
          output/raw.c output/matroska.c output/matroska_ebml.c \
          output/flv.c output/flv_bytestream.c filters/filters.c \
          filters/video/video.c filters/video/source.c filters/video/internal.c \
-         filters/video/resize.c filters/video/cache.c filters/video/fix_vfr_pts.c \
-         filters/video/select_every.c filters/video/crop.c filters/video/depth.c
+         filters/video/resize.c filters/video/fix_vfr_pts.c \
+         filters/video/select_every.c filters/video/crop.c
+
+SRCCLI_X = filters/video/cache.c filters/video/depth.c
 
 SRCSO =
+
+SRCCHK_X = tools/checkasm.c
+
+SRCEXAMPLE = example.c
+
 OBJS =
+OBJASM =
 OBJSO =
 OBJCLI =
-
-OBJCHK = tools/checkasm.o
-
-OBJEXAMPLE = example.o
+OBJCHK =
+OBJCHK_8 =
+OBJCHK_10 =
+OBJEXAMPLE =
 
 CONFIG := $(shell cat config.h)
 
@@ -51,8 +64,8 @@ SRCCLI += input/avs.c
 endif
 
 ifneq ($(findstring HAVE_THREAD 1, $(CONFIG)),)
-SRCCLI += input/thread.c
-SRCS   += common/threadpool.c
+SRCS_X   += common/threadpool.c
+SRCCLI_X += input/thread.c
 endif
 
 ifneq ($(findstring HAVE_WIN32THREAD 1, $(CONFIG)),)
@@ -75,85 +88,118 @@ ifneq ($(findstring HAVE_LSMASH 1, $(CONFIG)),)
 SRCCLI += output/mp4_lsmash.c
 endif
 
-# MMX/SSE optims
 ifneq ($(AS),)
-X86SRC0 = const-a.asm cabac-a.asm dct-a.asm deblock-a.asm mc-a.asm \
-          mc-a2.asm pixel-a.asm predict-a.asm quant-a.asm \
-          cpu-a.asm dct-32.asm bitstream-a.asm
-ifneq ($(findstring HIGH_BIT_DEPTH, $(CONFIG)),)
-X86SRC0 += sad16-a.asm
-else
-X86SRC0 += sad-a.asm
-endif
-X86SRC = $(X86SRC0:%=common/x86/%)
 
+# MMX/SSE optims
+SRCASM_X =
 ifeq ($(SYS_ARCH),X86)
 ARCH_X86 = yes
-ASMSRC   = $(X86SRC) common/x86/pixel-32.asm
+SRCASM_X += common/x86/dct-32.asm \
+            common/x86/pixel-32.asm
 endif
-
 ifeq ($(SYS_ARCH),X86_64)
 ARCH_X86 = yes
-ASMSRC   = $(X86SRC:-32.asm=-64.asm) common/x86/trellis-64.asm
+SRCASM_X += common/x86/dct-64.asm \
+            common/x86/trellis-64.asm
 endif
 
 ifdef ARCH_X86
-SRCS   += common/x86/mc-c.c common/x86/predict-c.c
-OBJASM  = $(ASMSRC:%.asm=%.o)
-$(OBJASM): common/x86/x86inc.asm common/x86/x86util.asm
-OBJCHK += tools/checkasm-a.o
+SRCASM_X += common/x86/bitstream-a.asm \
+            common/x86/const-a.asm \
+            common/x86/cabac-a.asm \
+            common/x86/dct-a.asm \
+            common/x86/deblock-a.asm \
+            common/x86/mc-a.asm \
+            common/x86/mc-a2.asm \
+            common/x86/pixel-a.asm \
+            common/x86/predict-a.asm \
+            common/x86/quant-a.asm
+SRCS_X   += common/x86/mc-c.c \
+            common/x86/predict-c.c
+
+OBJASM += common/x86/cpu-a.o
+ifneq ($(findstring HAVE_BITDEPTH8 1, $(CONFIG)),)
+OBJASM += $(SRCASM_X:%.asm=%-8.o) common/x86/sad-a-8.o
+endif
+ifneq ($(findstring HAVE_BITDEPTH10 1, $(CONFIG)),)
+OBJASM += $(SRCASM_X:%.asm=%-10.o) common/x86/sad16-a-10.o
 endif
+
+OBJCHK += tools/checkasm-a.o
 endif
 
 # AltiVec optims
 ifeq ($(SYS_ARCH),PPC)
-ifneq ($(AS),)
-SRCS += common/ppc/mc.c common/ppc/pixel.c common/ppc/dct.c \
-        common/ppc/quant.c common/ppc/deblock.c \
-        common/ppc/predict.c
-endif
+SRCS_X += common/ppc/dct.c \
+          common/ppc/deblock.c \
+          common/ppc/mc.c \
+          common/ppc/pixel.c \
+          common/ppc/predict.c \
+          common/ppc/quant.c
 endif
 
 # NEON optims
 ifeq ($(SYS_ARCH),ARM)
-ifneq ($(AS),)
-ASMSRC += common/arm/cpu-a.S common/arm/pixel-a.S common/arm/mc-a.S \
-          common/arm/dct-a.S common/arm/quant-a.S common/arm/deblock-a.S \
-          common/arm/predict-a.S common/arm/bitstream-a.S
-SRCS   += common/arm/mc-c.c common/arm/predict-c.c
-OBJASM  = $(ASMSRC:%.S=%.o)
-OBJCHK += tools/checkasm-arm.o
+SRCASM_X  = common/arm/bitstream-a.S \
+            common/arm/dct-a.S \
+            common/arm/deblock-a.S \
+            common/arm/mc-a.S \
+            common/arm/pixel-a.S \
+            common/arm/predict-a.S \
+            common/arm/quant-a.S
+SRCS_X   += common/arm/mc-c.c \
+            common/arm/predict-c.c
+
+OBJASM += common/arm/cpu-a.o
+ifneq ($(findstring HAVE_BITDEPTH8 1, $(CONFIG)),)
+OBJASM += $(SRCASM_X:%.S=%-8.o)
 endif
+ifneq ($(findstring HAVE_BITDEPTH10 1, $(CONFIG)),)
+OBJASM += $(SRCASM_X:%.S=%-10.o)
+endif
+
+OBJCHK += tools/checkasm-arm.o
 endif
 
 # AArch64 NEON optims
 ifeq ($(SYS_ARCH),AARCH64)
-ifneq ($(AS),)
-ASMSRC += common/aarch64/bitstream-a.S \
-          common/aarch64/cabac-a.S     \
-          common/aarch64/dct-a.S     \
-          common/aarch64/deblock-a.S \
-          common/aarch64/mc-a.S      \
-          common/aarch64/pixel-a.S   \
-          common/aarch64/predict-a.S \
-          common/aarch64/quant-a.S
-SRCS   += common/aarch64/asm-offsets.c \
-          common/aarch64/mc-c.c        \
-          common/aarch64/predict-c.c
-OBJASM  = $(ASMSRC:%.S=%.o)
-OBJCHK += tools/checkasm-aarch64.o
+SRCASM_X  = common/aarch64/bitstream-a.S \
+            common/aarch64/cabac-a.S \
+            common/aarch64/dct-a.S \
+            common/aarch64/deblock-a.S \
+            common/aarch64/mc-a.S \
+            common/aarch64/pixel-a.S \
+            common/aarch64/predict-a.S \
+            common/aarch64/quant-a.S
+SRCS_X   += common/aarch64/asm-offsets.c \
+            common/aarch64/mc-c.c \
+            common/aarch64/predict-c.c
+
+OBJASM +=
+ifneq ($(findstring HAVE_BITDEPTH8 1, $(CONFIG)),)
+OBJASM += $(SRCASM_X:%.S=%-8.o)
+endif
+ifneq ($(findstring HAVE_BITDEPTH10 1, $(CONFIG)),)
+OBJASM += $(SRCASM_X:%.S=%-10.o)
 endif
+
+OBJCHK += tools/checkasm-aarch64.o
 endif
 
 # MSA optims
 ifeq ($(SYS_ARCH),MIPS)
 ifneq ($(findstring HAVE_MSA 1, $(CONFIG)),)
-SRCS += common/mips/mc-c.c common/mips/dct-c.c \
-        common/mips/deblock-c.c common/mips/pixel-c.c \
-        common/mips/predict-c.c common/mips/quant-c.c
+SRCS_X += common/mips/dct-c.c \
+          common/mips/deblock-c.c \
+          common/mips/mc-c.c \
+          common/mips/pixel-c.c \
+          common/mips/predict-c.c \
+          common/mips/quant-c.c
 endif
 endif
 
+endif
+
 ifneq ($(HAVE_GETOPT_LONG),1)
 SRCCLI += extras/getopt.c
 endif
@@ -170,14 +216,28 @@ ifeq ($(HAVE_OPENCL),yes)
 common/oclobj.h: common/opencl/x264-cl.h $(wildcard $(SRCPATH)/common/opencl/*.cl)
        cat $^ | $(SRCPATH)/tools/cltostr.sh $@
 GENERATED += common/oclobj.h
-SRCS += common/opencl.c encoder/slicetype-cl.c
+SRCS_8 += common/opencl.c encoder/slicetype-cl.c
 endif
 
 OBJS   += $(SRCS:%.c=%.o)
 OBJCLI += $(SRCCLI:%.c=%.o)
 OBJSO  += $(SRCSO:%.c=%.o)
+OBJEXAMPLE += $(SRCEXAMPLE:%.c=%.o)
 
-.PHONY: all default fprofiled clean distclean install install-* uninstall cli lib-* etags
+ifneq ($(findstring HAVE_BITDEPTH8 1, $(CONFIG)),)
+OBJS      += $(SRCS_X:%.c=%-8.o) $(SRCS_8:%.c=%-8.o)
+OBJCLI    += $(SRCCLI_X:%.c=%-8.o)
+OBJCHK_8  += $(SRCCHK_X:%.c=%-8.o)
+checkasm: checkasm8$(EXE)
+endif
+ifneq ($(findstring HAVE_BITDEPTH10 1, $(CONFIG)),)
+OBJS      += $(SRCS_X:%.c=%-10.o)
+OBJCLI    += $(SRCCLI_X:%.c=%-10.o)
+OBJCHK_10 += $(SRCCHK_X:%.c=%-10.o)
+checkasm: checkasm10$(EXE)
+endif
+
+.PHONY: all default fprofiled clean distclean install install-* uninstall cli lib-* checkasm etags
 
 cli: x264$(EXE)
 lib-static: $(LIBX264)
@@ -192,31 +252,60 @@ $(SONAME): $(GENERATED) .depend $(OBJS) $(OBJASM) $(OBJSO)
        $(LD)$@ $(OBJS) $(OBJASM) $(OBJSO) $(SOFLAGS) $(LDFLAGS)
 
 ifneq ($(EXE),)
-.PHONY: x264 checkasm example
+.PHONY: x264 checkasm8 checkasm10 example
 x264: x264$(EXE)
-checkasm: checkasm$(EXE)
+checkasm8: checkasm8$(EXE)
+checkasm10: checkasm10$(EXE)
 example: example$(EXE)
 endif
 
 x264$(EXE): $(GENERATED) .depend $(OBJCLI) $(CLI_LIBX264)
        $(LD)$@ $(OBJCLI) $(CLI_LIBX264) $(LDFLAGSCLI) $(LDFLAGS)
 
-checkasm$(EXE): $(GENERATED) .depend $(OBJCHK) $(LIBX264)
-       $(LD)$@ $(OBJCHK) $(LIBX264) $(LDFLAGS)
+checkasm8$(EXE): $(GENERATED) .depend $(OBJCHK) $(OBJCHK_8) $(LIBX264)
+       $(LD)$@ $(OBJCHK) $(OBJCHK_8) $(LIBX264) $(LDFLAGS)
+
+checkasm10$(EXE): $(GENERATED) .depend $(OBJCHK) $(OBJCHK_10) $(LIBX264)
+       $(LD)$@ $(OBJCHK) $(OBJCHK_10) $(LIBX264) $(LDFLAGS)
 
 example$(EXE): $(GENERATED) .depend $(OBJEXAMPLE) $(LIBX264)
        $(LD)$@ $(OBJEXAMPLE) $(LIBX264) $(LDFLAGS)
 
-$(OBJS) $(OBJASM) $(OBJSO) $(OBJCLI) $(OBJCHK) $(OBJEXAMPLE): .depend
+$(OBJS) $(OBJASM) $(OBJSO) $(OBJCLI) $(OBJCHK) $(OBJCHK_8) $(OBJCHK_10) $(OBJEXAMPLE): .depend
+
+%.o: %.c
+       $(CC) $(CFLAGS) -c $< $(CC_O)
+
+%-8.o: %.c
+       $(CC) $(CFLAGS) -c $< $(CC_O) -DHIGH_BIT_DEPTH=0 -DBIT_DEPTH=8
+
+%-10.o: %.c
+       $(CC) $(CFLAGS) -c $< $(CC_O) -DHIGH_BIT_DEPTH=1 -DBIT_DEPTH=10
 
 %.o: %.asm common/x86/x86inc.asm common/x86/x86util.asm
        $(AS) $(ASFLAGS) -o $@ $<
        -@ $(if $(STRIP), $(STRIP) -x $@) # delete local/anonymous symbols, so they don't show up in oprofile
 
+%-8.o: %.asm common/x86/x86inc.asm common/x86/x86util.asm
+       $(AS) $(ASFLAGS) -o $@ $< -DBIT_DEPTH=8 -Dprivate_prefix=x264_8
+       -@ $(if $(STRIP), $(STRIP) -x $@)
+
+%-10.o: %.asm common/x86/x86inc.asm common/x86/x86util.asm
+       $(AS) $(ASFLAGS) -o $@ $< -DBIT_DEPTH=10 -Dprivate_prefix=x264_10
+       -@ $(if $(STRIP), $(STRIP) -x $@)
+
 %.o: %.S
        $(AS) $(ASFLAGS) -o $@ $<
        -@ $(if $(STRIP), $(STRIP) -x $@) # delete local/anonymous symbols, so they don't show up in oprofile
 
+%-8.o: %.S
+       $(AS) $(ASFLAGS) -o $@ $< -DHIGH_BIT_DEPTH=0 -DBIT_DEPTH=8
+       -@ $(if $(STRIP), $(STRIP) -x $@)
+
+%-10.o: %.S
+       $(AS) $(ASFLAGS) -o $@ $< -DHIGH_BIT_DEPTH=1 -DBIT_DEPTH=10
+       -@ $(if $(STRIP), $(STRIP) -x $@)
+
 %.dll.o: %.rc x264.h
        $(RC) $(RCFLAGS)$@ -DDLL $<
 
@@ -227,9 +316,21 @@ $(OBJS) $(OBJASM) $(OBJSO) $(OBJCLI) $(OBJCHK) $(OBJEXAMPLE): .depend
        @rm -f .depend
        @echo 'dependency file generation...'
 ifeq ($(COMPILER),CL)
-       @$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCS) $(SRCCLI) $(SRCSO)), $(SRCPATH)/tools/msvsdepend.sh "$(CC)" "$(CFLAGS)" "$(SRC)" "$(SRC:$(SRCPATH)/%.c=%.o)" 1>> .depend;)
+       @$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCS) $(SRCCLI) $(SRCSO) $(SRCEXAMPLE)), $(SRCPATH)/tools/msvsdepend.sh "$(CC)" "$(CFLAGS)" "$(SRC)" "$(SRC:$(SRCPATH)/%.c=%.o)" 1>> .depend;)
+ifneq ($(findstring HAVE_BITDEPTH8 1, $(CONFIG)),)
+       @$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCS_X) $(SRCS_8) $(SRCCLI_X) $(SRCCHK_X)), $(SRCPATH)/tools/msvsdepend.sh "$(CC)" "$(CFLAGS)" "$(SRC)" "$(SRC:$(SRCPATH)/%.c=%-8.o)" 1>> .depend;)
+endif
+ifneq ($(findstring HAVE_BITDEPTH10 1, $(CONFIG)),)
+       @$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCS_X) $(SRCCLI_X) $(SRCCHK_X)), $(SRCPATH)/tools/msvsdepend.sh "$(CC)" "$(CFLAGS)" "$(SRC)" "$(SRC:$(SRCPATH)/%.c=%-10.o)" 1>> .depend;)
+endif
 else
-       @$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCS) $(SRCCLI) $(SRCSO)), $(CC) $(CFLAGS) $(SRC) $(DEPMT) $(SRC:$(SRCPATH)/%.c=%.o) $(DEPMM) 1>> .depend;)
+       @$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCS) $(SRCCLI) $(SRCSO) $(SRCEXAMPLE)), $(CC) $(CFLAGS) $(SRC) $(DEPMT) $(SRC:$(SRCPATH)/%.c=%.o) $(DEPMM) 1>> .depend;)
+ifneq ($(findstring HAVE_BITDEPTH8 1, $(CONFIG)),)
+       @$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCS_X) $(SRCS_8) $(SRCCLI_X) $(SRCCHK_X)), $(CC) $(CFLAGS) $(SRC) $(DEPMT) $(SRC:$(SRCPATH)/%.c=%-8.o) $(DEPMM) 1>> .depend;)
+endif
+ifneq ($(findstring HAVE_BITDEPTH10 1, $(CONFIG)),)
+       @$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCS_X) $(SRCCLI_X) $(SRCCHK_X)), $(CC) $(CFLAGS) $(SRC) $(DEPMT) $(SRC:$(SRCPATH)/%.c=%-10.o) $(DEPMM) 1>> .depend;)
+endif
 endif
 
 config.mak:
@@ -240,7 +341,7 @@ ifneq ($(wildcard .depend),)
 include .depend
 endif
 
-SRC2 = $(SRCS) $(SRCCLI)
+OBJPROF = $(OBJS) $(OBJCLI)
 # These should cover most of the important codepaths
 OPT0 = --crf 30 -b1 -m1 -r1 --me dia --no-cabac --direct temporal --ssim --no-weightb
 OPT1 = --crf 16 -b2 -m3 -r3 --me hex --no-8x8dct --direct spatial --no-dct-decimate -t0  --slice-max-mbs 50
@@ -265,17 +366,18 @@ ifeq ($(COMPILER),CL)
 # Because Visual Studio timestamps the object files within the PGD, it fails to build if they change - only the executable should be deleted
        rm -f x264$(EXE)
 else
-       rm -f $(SRC2:%.c=%.o)
+       rm -f $(OBJPROF)
 endif
        $(MAKE) CFLAGS="$(CFLAGS) $(PROF_USE_CC)" LDFLAGS="$(LDFLAGS) $(PROF_USE_LD)"
-       rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno) *.dyn pgopti.dpi pgopti.dpi.lock *.pgd *.pgc
+       rm -f $(OBJPROF:%.o=%.gcda) $(OBJPROF:%.o=%.gcno) *.dyn pgopti.dpi pgopti.dpi.lock *.pgd *.pgc
 endif
 
 clean:
-       rm -f $(OBJS) $(OBJASM) $(OBJCLI) $(OBJSO) $(SONAME) *.a *.lib *.exp *.pdb x264 x264.exe .depend TAGS
-       rm -f checkasm checkasm.exe $(OBJCHK) $(GENERATED) x264_lookahead.clbin
-       rm -f example example.exe $(OBJEXAMPLE)
-       rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno) *.dyn pgopti.dpi pgopti.dpi.lock *.pgd *.pgc
+       rm -f $(OBJS) $(OBJASM) $(OBJCLI) $(OBJSO) $(GENERATED) .depend TAGS
+       rm -f $(SONAME) *.a *.lib *.exp *.pdb x264$(EXE) x264_lookahead.clbin
+       rm -f checkasm8$(EXE) checkasm10$(EXE) $(OBJCHK) $(OBJCHK_8) $(OBJCHK_10)
+       rm -f example$(EXE) $(OBJEXAMPLE)
+       rm -f $(OBJPROF:%.o=%.gcda) $(OBJPROF:%.o=%.gcno) *.dyn pgopti.dpi pgopti.dpi.lock *.pgd *.pgc
 
 distclean: clean
        rm -f config.mak x264_config.h config.h config.log x264.pc x264.def
@@ -319,4 +421,4 @@ endif
 etags: TAGS
 
 TAGS:
-       etags $(SRCS)
+       etags $(SRCS) $(SRCS_X) $(SRCS_8)
index 658a1dd94b626d7edf31c11e85f58e14f40e4635..15fb4123263b60ab15f64325393078990ae68c91 100644 (file)
 
 #include "config.h"
 
+#define GLUE(a, b) a ## b
+#define JOIN(a, b) GLUE(a, b)
+
 #ifdef PREFIX
-#   define EXTERN_ASM _x264_
+#   define BASE _x264_
+#   define SYM_PREFIX _
+#else
+#   define BASE x264_
+#   define SYM_PREFIX
+#endif
+
+#ifdef BIT_DEPTH
+#   define EXTERN_ASM JOIN(JOIN(BASE, BIT_DEPTH), _)
 #else
-#   define EXTERN_ASM x264_
+#   define EXTERN_ASM BASE
 #endif
 
+#define X(s) JOIN(EXTERN_ASM, s)
+#define X264(s) JOIN(BASE, s)
+#define EXT(s) JOIN(SYM_PREFIX, s)
+
 #ifdef __ELF__
 #   define ELF
 #else
@@ -98,10 +113,6 @@ MACH    .const_data
 #endif
 .endm
 
-#define GLUE(a, b) a ## b
-#define JOIN(a, b) GLUE(a, b)
-#define X(s) JOIN(EXTERN_ASM, s)
-
 #define FDEC_STRIDE 32
 #define FENC_STRIDE 16
 
diff --git a/common/aarch64/bitstream.h b/common/aarch64/bitstream.h
new file mode 100644 (file)
index 0000000..bc2ce6a
--- /dev/null
@@ -0,0 +1,32 @@
+/*****************************************************************************
+ * bitstream.h: aarch64 bitstream functions
+ *****************************************************************************
+ * Copyright (C) 2017 x264 project
+ *
+ * Authors: Anton Mitrofanov <BugMaster@narod.ru>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@x264.com.
+ *****************************************************************************/
+
+#ifndef X264_AARCH64_BITSTREAM_H
+#define X264_AARCH64_BITSTREAM_H
+
+#define x264_nal_escape_neon x264_template(nal_escape_neon)
+uint8_t *x264_nal_escape_neon( uint8_t *dst, uint8_t *src, uint8_t *end );
+
+#endif
index 7f8fa84b8e41a887ebda0c0a589616d8976cacb9..c05f963de496a368c60dd84c9decd375c50479aa 100644 (file)
@@ -30,8 +30,8 @@
 // w12 holds x264_cabac_t.i_range
 
 function cabac_encode_decision_asm, export=1
-    movrel      x8,  X(cabac_range_lps)
-    movrel      x9,  X(cabac_transition)
+    movrel      x8,  X264(cabac_range_lps)
+    movrel      x9,  X264(cabac_transition)
     add         w10, w1, #CABAC_STATE
     ldrb        w3,  [x0,  x10]         // i_state
     ldr         w12, [x0,  #CABAC_I_RANGE]
index 095f4ab5d0aed821edcafd9d0c540df855777720..c0c557869535997772cba0846c96a16b93679b8f 100644 (file)
 #ifndef X264_AARCH64_DCT_H
 #define X264_AARCH64_DCT_H
 
+#define x264_dct4x4dc_neon x264_template(dct4x4dc_neon)
 void x264_dct4x4dc_neon( int16_t d[16] );
+#define x264_idct4x4dc_neon x264_template(idct4x4dc_neon)
 void x264_idct4x4dc_neon( int16_t d[16] );
 
+#define x264_sub4x4_dct_neon x264_template(sub4x4_dct_neon)
 void x264_sub4x4_dct_neon( int16_t dct[16], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub8x8_dct_neon x264_template(sub8x8_dct_neon)
 void x264_sub8x8_dct_neon( int16_t dct[4][16], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub16x16_dct_neon x264_template(sub16x16_dct_neon)
 void x264_sub16x16_dct_neon( int16_t dct[16][16], uint8_t *pix1, uint8_t *pix2 );
 
+#define x264_add4x4_idct_neon x264_template(add4x4_idct_neon)
 void x264_add4x4_idct_neon( uint8_t *p_dst, int16_t dct[16] );
+#define x264_add8x8_idct_neon x264_template(add8x8_idct_neon)
 void x264_add8x8_idct_neon( uint8_t *p_dst, int16_t dct[4][16] );
+#define x264_add16x16_idct_neon x264_template(add16x16_idct_neon)
 void x264_add16x16_idct_neon( uint8_t *p_dst, int16_t dct[16][16] );
 
+#define x264_add8x8_idct_dc_neon x264_template(add8x8_idct_dc_neon)
 void x264_add8x8_idct_dc_neon( uint8_t *p_dst, int16_t dct[4] );
+#define x264_add16x16_idct_dc_neon x264_template(add16x16_idct_dc_neon)
 void x264_add16x16_idct_dc_neon( uint8_t *p_dst, int16_t dct[16] );
+#define x264_sub8x8_dct_dc_neon x264_template(sub8x8_dct_dc_neon)
 void x264_sub8x8_dct_dc_neon( int16_t dct[4], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub8x16_dct_dc_neon x264_template(sub8x16_dct_dc_neon)
 void x264_sub8x16_dct_dc_neon( int16_t dct[8], uint8_t *pix1, uint8_t *pix2 );
 
+#define x264_sub8x8_dct8_neon x264_template(sub8x8_dct8_neon)
 void x264_sub8x8_dct8_neon( int16_t dct[64], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub16x16_dct8_neon x264_template(sub16x16_dct8_neon)
 void x264_sub16x16_dct8_neon( int16_t dct[4][64], uint8_t *pix1, uint8_t *pix2 );
 
+#define x264_add8x8_idct8_neon x264_template(add8x8_idct8_neon)
 void x264_add8x8_idct8_neon( uint8_t *p_dst, int16_t dct[64] );
+#define x264_add16x16_idct8_neon x264_template(add16x16_idct8_neon)
 void x264_add16x16_idct8_neon( uint8_t *p_dst, int16_t dct[4][64] );
 
+#define x264_zigzag_scan_4x4_frame_neon x264_template(zigzag_scan_4x4_frame_neon)
 void x264_zigzag_scan_4x4_frame_neon( int16_t level[16], int16_t dct[16] );
+#define x264_zigzag_scan_4x4_field_neon x264_template(zigzag_scan_4x4_field_neon)
 void x264_zigzag_scan_4x4_field_neon( int16_t level[16], int16_t dct[16] );
+#define x264_zigzag_scan_8x8_frame_neon x264_template(zigzag_scan_8x8_frame_neon)
 void x264_zigzag_scan_8x8_frame_neon( int16_t level[64], int16_t dct[64] );
+#define x264_zigzag_scan_8x8_field_neon x264_template(zigzag_scan_8x8_field_neon)
 void x264_zigzag_scan_8x8_field_neon( int16_t level[64], int16_t dct[64] );
 
+#define x264_zigzag_sub_4x4_field_neon x264_template(zigzag_sub_4x4_field_neon)
 int x264_zigzag_sub_4x4_field_neon( dctcoef level[16], const pixel *p_src, pixel *p_dst );
+#define x264_zigzag_sub_4x4ac_field_neon x264_template(zigzag_sub_4x4ac_field_neon)
 int x264_zigzag_sub_4x4ac_field_neon( dctcoef level[16], const pixel *p_src, pixel *p_dst, dctcoef *dc );
+#define x264_zigzag_sub_4x4_frame_neon x264_template(zigzag_sub_4x4_frame_neon)
 int x264_zigzag_sub_4x4_frame_neon( dctcoef level[16], const pixel *p_src, pixel *p_dst );
+#define x264_zigzag_sub_4x4ac_frame_neon x264_template(zigzag_sub_4x4ac_frame_neon)
 int x264_zigzag_sub_4x4ac_frame_neon( dctcoef level[16], const pixel *p_src, pixel *p_dst, dctcoef *dc );
 
+#define x264_zigzag_sub_8x8_field_neon x264_template(zigzag_sub_8x8_field_neon)
 int x264_zigzag_sub_8x8_field_neon( dctcoef level[16], const pixel *p_src, pixel *p_dst );
+#define x264_zigzag_sub_8x8_frame_neon x264_template(zigzag_sub_8x8_frame_neon)
 int x264_zigzag_sub_8x8_frame_neon( dctcoef level[16], const pixel *p_src, pixel *p_dst );
 
+#define x264_zigzag_interleave_8x8_cavlc_neon x264_template(zigzag_interleave_8x8_cavlc_neon)
 void x264_zigzag_interleave_8x8_cavlc_neon( dctcoef *dst, dctcoef *src, uint8_t *nnz );
 
 #endif
diff --git a/common/aarch64/deblock.h b/common/aarch64/deblock.h
new file mode 100644 (file)
index 0000000..e796acb
--- /dev/null
@@ -0,0 +1,58 @@
+/*****************************************************************************
+ * deblock.h: aarch64 deblocking
+ *****************************************************************************
+ * Copyright (C) 2017 x264 project
+ *
+ * Authors: Anton Mitrofanov <BugMaster@narod.ru>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@x264.com.
+ *****************************************************************************/
+
+#ifndef X264_AARCH64_DEBLOCK_H
+#define X264_AARCH64_DEBLOCK_H
+
+#define x264_deblock_v_luma_neon x264_template(deblock_v_luma_neon)
+void x264_deblock_v_luma_neon  ( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_h_luma_neon x264_template(deblock_h_luma_neon)
+void x264_deblock_h_luma_neon  ( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_v_chroma_neon x264_template(deblock_v_chroma_neon)
+void x264_deblock_v_chroma_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_h_chroma_neon x264_template(deblock_h_chroma_neon)
+void x264_deblock_h_chroma_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_strength_neon x264_template(deblock_strength_neon)
+void x264_deblock_strength_neon( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE],
+                                 int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][8][4],
+                                 int mvy_limit, int bframe );
+#define x264_deblock_h_chroma_422_neon x264_template(deblock_h_chroma_422_neon)
+void x264_deblock_h_chroma_422_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_h_chroma_mbaff_neon x264_template(deblock_h_chroma_mbaff_neon)
+void x264_deblock_h_chroma_mbaff_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_h_chroma_intra_mbaff_neon x264_template(deblock_h_chroma_intra_mbaff_neon)
+void x264_deblock_h_chroma_intra_mbaff_neon( uint8_t *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_h_chroma_intra_neon x264_template(deblock_h_chroma_intra_neon)
+void x264_deblock_h_chroma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_h_chroma_422_intra_neon x264_template(deblock_h_chroma_422_intra_neon)
+void x264_deblock_h_chroma_422_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_v_chroma_intra_neon x264_template(deblock_v_chroma_intra_neon)
+void x264_deblock_v_chroma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_h_luma_intra_neon x264_template(deblock_h_luma_intra_neon)
+void x264_deblock_h_luma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_v_luma_intra_neon x264_template(deblock_v_luma_intra_neon)
+void x264_deblock_v_luma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta );
+
+#endif
index 793662afd6111e3b27b8c556d7c6b8ce0571507b..2602670f9b78dad9fa0153fcdd0fa294299eff36 100644 (file)
 #include "common/common.h"
 #include "mc.h"
 
+#define x264_prefetch_ref_aarch64 x264_template(prefetch_ref_aarch64)
 void x264_prefetch_ref_aarch64( uint8_t *, intptr_t, int );
+#define x264_prefetch_fenc_420_aarch64 x264_template(prefetch_fenc_420_aarch64)
 void x264_prefetch_fenc_420_aarch64( uint8_t *, intptr_t, uint8_t *, intptr_t, int );
+#define x264_prefetch_fenc_422_aarch64 x264_template(prefetch_fenc_422_aarch64)
 void x264_prefetch_fenc_422_aarch64( uint8_t *, intptr_t, uint8_t *, intptr_t, int );
 
+#define x264_memcpy_aligned_neon x264_template(memcpy_aligned_neon)
 void *x264_memcpy_aligned_neon( void *dst, const void *src, size_t n );
+#define x264_memzero_aligned_neon x264_template(memzero_aligned_neon)
 void x264_memzero_aligned_neon( void *dst, size_t n );
 
+#define x264_pixel_avg_16x16_neon x264_template(pixel_avg_16x16_neon)
 void x264_pixel_avg_16x16_neon( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, intptr_t, int );
+#define x264_pixel_avg_16x8_neon x264_template(pixel_avg_16x8_neon)
 void x264_pixel_avg_16x8_neon ( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, intptr_t, int );
+#define x264_pixel_avg_8x16_neon x264_template(pixel_avg_8x16_neon)
 void x264_pixel_avg_8x16_neon ( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, intptr_t, int );
+#define x264_pixel_avg_8x8_neon x264_template(pixel_avg_8x8_neon)
 void x264_pixel_avg_8x8_neon  ( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, intptr_t, int );
+#define x264_pixel_avg_8x4_neon x264_template(pixel_avg_8x4_neon)
 void x264_pixel_avg_8x4_neon  ( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, intptr_t, int );
+#define x264_pixel_avg_4x16_neon x264_template(pixel_avg_4x16_neon)
 void x264_pixel_avg_4x16_neon ( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, intptr_t, int );
+#define x264_pixel_avg_4x8_neon x264_template(pixel_avg_4x8_neon)
 void x264_pixel_avg_4x8_neon  ( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, intptr_t, int );
+#define x264_pixel_avg_4x4_neon x264_template(pixel_avg_4x4_neon)
 void x264_pixel_avg_4x4_neon  ( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, intptr_t, int );
+#define x264_pixel_avg_4x2_neon x264_template(pixel_avg_4x2_neon)
 void x264_pixel_avg_4x2_neon  ( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, intptr_t, int );
 
+#define x264_pixel_avg2_w4_neon x264_template(pixel_avg2_w4_neon)
 void x264_pixel_avg2_w4_neon ( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, int );
+#define x264_pixel_avg2_w8_neon x264_template(pixel_avg2_w8_neon)
 void x264_pixel_avg2_w8_neon ( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, int );
+#define x264_pixel_avg2_w16_neon x264_template(pixel_avg2_w16_neon)
 void x264_pixel_avg2_w16_neon( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, int );
+#define x264_pixel_avg2_w20_neon x264_template(pixel_avg2_w20_neon)
 void x264_pixel_avg2_w20_neon( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, int );
 
+#define x264_plane_copy_core_neon x264_template(plane_copy_core_neon)
 void x264_plane_copy_core_neon( pixel *dst, intptr_t i_dst,
                                 pixel *src, intptr_t i_src, int w, int h );
+#define x264_plane_copy_swap_core_neon x264_template(plane_copy_swap_core_neon)
 void x264_plane_copy_swap_core_neon( pixel *dst, intptr_t i_dst,
                                      pixel *src, intptr_t i_src, int w, int h );
+#define x264_plane_copy_deinterleave_neon x264_template(plane_copy_deinterleave_neon)
 void x264_plane_copy_deinterleave_neon(  pixel *dstu, intptr_t i_dstu,
                                          pixel *dstv, intptr_t i_dstv,
                                          pixel *src,  intptr_t i_src, int w, int h );
+#define x264_plane_copy_deinterleave_rgb_neon x264_template(plane_copy_deinterleave_rgb_neon)
 void x264_plane_copy_deinterleave_rgb_neon( pixel *dsta, intptr_t i_dsta,
                                             pixel *dstb, intptr_t i_dstb,
                                             pixel *dstc, intptr_t i_dstc,
                                             pixel *src,  intptr_t i_src, int pw, int w, int h );
+#define x264_plane_copy_interleave_core_neon x264_template(plane_copy_interleave_core_neon)
 void x264_plane_copy_interleave_core_neon( pixel *dst,  intptr_t i_dst,
                                            pixel *srcu, intptr_t i_srcu,
                                            pixel *srcv, intptr_t i_srcv, int w, int h );
 
+#define x264_store_interleave_chroma_neon x264_template(store_interleave_chroma_neon)
 void x264_store_interleave_chroma_neon( pixel *dst, intptr_t i_dst, pixel *srcu, pixel *srcv, int height );
+#define x264_load_deinterleave_chroma_fdec_neon x264_template(load_deinterleave_chroma_fdec_neon)
 void x264_load_deinterleave_chroma_fdec_neon( pixel *dst, pixel *src, intptr_t i_src, int height );
+#define x264_load_deinterleave_chroma_fenc_neon x264_template(load_deinterleave_chroma_fenc_neon)
 void x264_load_deinterleave_chroma_fenc_neon( pixel *dst, pixel *src, intptr_t i_src, int height );
 
+#define x264_mc_weight_w16_neon x264_template(mc_weight_w16_neon)
+#define x264_mc_weight_w16_nodenom_neon x264_template(mc_weight_w16_nodenom_neon)
+#define x264_mc_weight_w16_offsetadd_neon x264_template(mc_weight_w16_offsetadd_neon)
+#define x264_mc_weight_w16_offsetsub_neon x264_template(mc_weight_w16_offsetsub_neon)
+#define x264_mc_weight_w20_neon x264_template(mc_weight_w20_neon)
+#define x264_mc_weight_w20_nodenom_neon x264_template(mc_weight_w20_nodenom_neon)
+#define x264_mc_weight_w20_offsetadd_neon x264_template(mc_weight_w20_offsetadd_neon)
+#define x264_mc_weight_w20_offsetsub_neon x264_template(mc_weight_w20_offsetsub_neon)
+#define x264_mc_weight_w4_neon x264_template(mc_weight_w4_neon)
+#define x264_mc_weight_w4_nodenom_neon x264_template(mc_weight_w4_nodenom_neon)
+#define x264_mc_weight_w4_offsetadd_neon x264_template(mc_weight_w4_offsetadd_neon)
+#define x264_mc_weight_w4_offsetsub_neon x264_template(mc_weight_w4_offsetsub_neon)
+#define x264_mc_weight_w8_neon x264_template(mc_weight_w8_neon)
+#define x264_mc_weight_w8_nodenom_neon x264_template(mc_weight_w8_nodenom_neon)
+#define x264_mc_weight_w8_offsetadd_neon x264_template(mc_weight_w8_offsetadd_neon)
+#define x264_mc_weight_w8_offsetsub_neon x264_template(mc_weight_w8_offsetsub_neon)
 #define MC_WEIGHT(func)\
 void x264_mc_weight_w20##func##_neon( uint8_t *, intptr_t, uint8_t *, intptr_t, const x264_weight_t *, int );\
 void x264_mc_weight_w16##func##_neon( uint8_t *, intptr_t, uint8_t *, intptr_t, const x264_weight_t *, int );\
@@ -84,25 +126,39 @@ static void (* mc##func##_wtab_neon[6])( uint8_t *, intptr_t, uint8_t *, intptr_
     x264_mc_weight_w20##func##_neon,\
 };
 
+#if !HIGH_BIT_DEPTH
 MC_WEIGHT()
 MC_WEIGHT(_nodenom)
 MC_WEIGHT(_offsetadd)
 MC_WEIGHT(_offsetsub)
+#endif
 
+#define x264_mc_copy_w4_neon x264_template(mc_copy_w4_neon)
 void x264_mc_copy_w4_neon ( uint8_t *, intptr_t, uint8_t *, intptr_t, int );
+#define x264_mc_copy_w8_neon x264_template(mc_copy_w8_neon)
 void x264_mc_copy_w8_neon ( uint8_t *, intptr_t, uint8_t *, intptr_t, int );
+#define x264_mc_copy_w16_neon x264_template(mc_copy_w16_neon)
 void x264_mc_copy_w16_neon( uint8_t *, intptr_t, uint8_t *, intptr_t, int );
 
+#define x264_mc_chroma_neon x264_template(mc_chroma_neon)
 void x264_mc_chroma_neon( uint8_t *, uint8_t *, intptr_t, uint8_t *, intptr_t, int, int, int, int );
+#define x264_integral_init4h_neon x264_template(integral_init4h_neon)
 void x264_integral_init4h_neon( uint16_t *, uint8_t *, intptr_t );
+#define x264_integral_init4v_neon x264_template(integral_init4v_neon)
 void x264_integral_init4v_neon( uint16_t *, uint16_t *, intptr_t );
+#define x264_integral_init8h_neon x264_template(integral_init8h_neon)
 void x264_integral_init8h_neon( uint16_t *, uint8_t *, intptr_t );
+#define x264_integral_init8v_neon x264_template(integral_init8v_neon)
 void x264_integral_init8v_neon( uint16_t *, intptr_t );
+#define x264_frame_init_lowres_core_neon x264_template(frame_init_lowres_core_neon)
 void x264_frame_init_lowres_core_neon( uint8_t *, uint8_t *, uint8_t *, uint8_t *, uint8_t *, intptr_t, intptr_t, int, int );
 
+#define x264_mbtree_propagate_cost_neon x264_template(mbtree_propagate_cost_neon)
 void x264_mbtree_propagate_cost_neon( int16_t *, uint16_t *, uint16_t *, uint16_t *, uint16_t *, float *, int );
 
+#define x264_mbtree_fix8_pack_neon x264_template(mbtree_fix8_pack_neon)
 void x264_mbtree_fix8_pack_neon( uint16_t *dst, float *src, int count );
+#define x264_mbtree_fix8_unpack_neon x264_template(mbtree_fix8_unpack_neon)
 void x264_mbtree_fix8_unpack_neon( float *dst, uint16_t *src, int count );
 
 #if !HIGH_BIT_DEPTH
@@ -205,6 +261,7 @@ static uint8_t *get_ref_neon( uint8_t *dst,   intptr_t *i_dst_stride,
     }
 }
 
+#define x264_hpel_filter_neon x264_template(hpel_filter_neon)
 void x264_hpel_filter_neon( uint8_t *dsth, uint8_t *dstv, uint8_t *dstc,
                             uint8_t *src, intptr_t stride, int width,
                             int height, int16_t *buf );
@@ -212,9 +269,8 @@ void x264_hpel_filter_neon( uint8_t *dsth, uint8_t *dstv, uint8_t *dstc,
 PLANE_COPY(16, neon)
 PLANE_COPY_SWAP(16, neon)
 PLANE_INTERLEAVE(neon)
-#endif // !HIGH_BIT_DEPTH
-
 PROPAGATE_LIST(neon)
+#endif // !HIGH_BIT_DEPTH
 
 void x264_mc_init_aarch64( int cpu, x264_mc_functions_t *pf )
 {
index 33c311e939a6c1ad73c161837329b99323a3605b..cda737918d62eec4ee1e233300000cadab186cc0 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef X264_AARCH64_MC_H
 #define X264_AARCH64_MC_H
 
+#define x264_mc_init_aarch64 x264_template(mc_init_aarch64)
 void x264_mc_init_aarch64( int cpu, x264_mc_functions_t *pf );
 
 #endif
index 5206a0c7f02bb29289679570daab91c41cd83060..8b2bf594969f2513ef3fe0b07d5cc8e435c8996b 100644 (file)
 #ifndef X264_AARCH64_PIXEL_H
 #define X264_AARCH64_PIXEL_H
 
+#define x264_pixel_sad_16x16_neon x264_template(pixel_sad_16x16_neon)
+#define x264_pixel_sad_16x8_neon x264_template(pixel_sad_16x8_neon)
+#define x264_pixel_sad_4x16_neon x264_template(pixel_sad_4x16_neon)
+#define x264_pixel_sad_4x4_neon x264_template(pixel_sad_4x4_neon)
+#define x264_pixel_sad_4x8_neon x264_template(pixel_sad_4x8_neon)
+#define x264_pixel_sad_8x16_neon x264_template(pixel_sad_8x16_neon)
+#define x264_pixel_sad_8x4_neon x264_template(pixel_sad_8x4_neon)
+#define x264_pixel_sad_8x8_neon x264_template(pixel_sad_8x8_neon)
+#define x264_pixel_sad_x3_16x16_neon x264_template(pixel_sad_x3_16x16_neon)
+#define x264_pixel_sad_x3_16x8_neon x264_template(pixel_sad_x3_16x8_neon)
+#define x264_pixel_sad_x3_4x4_neon x264_template(pixel_sad_x3_4x4_neon)
+#define x264_pixel_sad_x3_4x8_neon x264_template(pixel_sad_x3_4x8_neon)
+#define x264_pixel_sad_x3_8x16_neon x264_template(pixel_sad_x3_8x16_neon)
+#define x264_pixel_sad_x3_8x4_neon x264_template(pixel_sad_x3_8x4_neon)
+#define x264_pixel_sad_x3_8x8_neon x264_template(pixel_sad_x3_8x8_neon)
+#define x264_pixel_sad_x4_16x16_neon x264_template(pixel_sad_x4_16x16_neon)
+#define x264_pixel_sad_x4_16x8_neon x264_template(pixel_sad_x4_16x8_neon)
+#define x264_pixel_sad_x4_4x4_neon x264_template(pixel_sad_x4_4x4_neon)
+#define x264_pixel_sad_x4_4x8_neon x264_template(pixel_sad_x4_4x8_neon)
+#define x264_pixel_sad_x4_8x16_neon x264_template(pixel_sad_x4_8x16_neon)
+#define x264_pixel_sad_x4_8x4_neon x264_template(pixel_sad_x4_8x4_neon)
+#define x264_pixel_sad_x4_8x8_neon x264_template(pixel_sad_x4_8x8_neon)
+#define x264_pixel_satd_16x16_neon x264_template(pixel_satd_16x16_neon)
+#define x264_pixel_satd_16x8_neon x264_template(pixel_satd_16x8_neon)
+#define x264_pixel_satd_4x16_neon x264_template(pixel_satd_4x16_neon)
+#define x264_pixel_satd_4x4_neon x264_template(pixel_satd_4x4_neon)
+#define x264_pixel_satd_4x8_neon x264_template(pixel_satd_4x8_neon)
+#define x264_pixel_satd_8x16_neon x264_template(pixel_satd_8x16_neon)
+#define x264_pixel_satd_8x4_neon x264_template(pixel_satd_8x4_neon)
+#define x264_pixel_satd_8x8_neon x264_template(pixel_satd_8x8_neon)
+#define x264_pixel_ssd_16x16_neon x264_template(pixel_ssd_16x16_neon)
+#define x264_pixel_ssd_16x8_neon x264_template(pixel_ssd_16x8_neon)
+#define x264_pixel_ssd_4x16_neon x264_template(pixel_ssd_4x16_neon)
+#define x264_pixel_ssd_4x4_neon x264_template(pixel_ssd_4x4_neon)
+#define x264_pixel_ssd_4x8_neon x264_template(pixel_ssd_4x8_neon)
+#define x264_pixel_ssd_8x16_neon x264_template(pixel_ssd_8x16_neon)
+#define x264_pixel_ssd_8x4_neon x264_template(pixel_ssd_8x4_neon)
+#define x264_pixel_ssd_8x8_neon x264_template(pixel_ssd_8x8_neon)
 #define DECL_PIXELS( ret, name, suffix, args ) \
     ret x264_pixel_##name##_16x16_##suffix args;\
     ret x264_pixel_##name##_16x8_##suffix args;\
@@ -50,30 +88,47 @@ DECL_X1( satd, neon )
 DECL_X1( ssd, neon )
 
 
+#define x264_pixel_ssd_nv12_core_neon x264_template(pixel_ssd_nv12_core_neon)
 void x264_pixel_ssd_nv12_core_neon( uint8_t *, intptr_t, uint8_t *, intptr_t, int, int, uint64_t *, uint64_t * );
 
+#define x264_pixel_vsad_neon x264_template(pixel_vsad_neon)
 int x264_pixel_vsad_neon( uint8_t *, intptr_t, int );
 
+#define x264_pixel_sa8d_8x8_neon x264_template(pixel_sa8d_8x8_neon)
 int x264_pixel_sa8d_8x8_neon  ( uint8_t *, intptr_t, uint8_t *, intptr_t );
+#define x264_pixel_sa8d_16x16_neon x264_template(pixel_sa8d_16x16_neon)
 int x264_pixel_sa8d_16x16_neon( uint8_t *, intptr_t, uint8_t *, intptr_t );
+#define x264_pixel_sa8d_satd_16x16_neon x264_template(pixel_sa8d_satd_16x16_neon)
 uint64_t x264_pixel_sa8d_satd_16x16_neon( uint8_t *, intptr_t, uint8_t *, intptr_t );
 
+#define x264_pixel_var_8x8_neon x264_template(pixel_var_8x8_neon)
 uint64_t x264_pixel_var_8x8_neon  ( uint8_t *, intptr_t );
+#define x264_pixel_var_8x16_neon x264_template(pixel_var_8x16_neon)
 uint64_t x264_pixel_var_8x16_neon ( uint8_t *, intptr_t );
+#define x264_pixel_var_16x16_neon x264_template(pixel_var_16x16_neon)
 uint64_t x264_pixel_var_16x16_neon( uint8_t *, intptr_t );
+#define x264_pixel_var2_8x8_neon x264_template(pixel_var2_8x8_neon)
 int x264_pixel_var2_8x8_neon ( uint8_t *, uint8_t *, int * );
+#define x264_pixel_var2_8x16_neon x264_template(pixel_var2_8x16_neon)
 int x264_pixel_var2_8x16_neon( uint8_t *, uint8_t *, int * );
 
+#define x264_pixel_hadamard_ac_8x8_neon x264_template(pixel_hadamard_ac_8x8_neon)
 uint64_t x264_pixel_hadamard_ac_8x8_neon  ( uint8_t *, intptr_t );
+#define x264_pixel_hadamard_ac_8x16_neon x264_template(pixel_hadamard_ac_8x16_neon)
 uint64_t x264_pixel_hadamard_ac_8x16_neon ( uint8_t *, intptr_t );
+#define x264_pixel_hadamard_ac_16x8_neon x264_template(pixel_hadamard_ac_16x8_neon)
 uint64_t x264_pixel_hadamard_ac_16x8_neon ( uint8_t *, intptr_t );
+#define x264_pixel_hadamard_ac_16x16_neon x264_template(pixel_hadamard_ac_16x16_neon)
 uint64_t x264_pixel_hadamard_ac_16x16_neon( uint8_t *, intptr_t );
 
+#define x264_pixel_ssim_4x4x2_core_neon x264_template(pixel_ssim_4x4x2_core_neon)
 void x264_pixel_ssim_4x4x2_core_neon( const uint8_t *, intptr_t,
                                       const uint8_t *, intptr_t,
                                       int sums[2][4] );
+#define x264_pixel_ssim_end4_neon x264_template(pixel_ssim_end4_neon)
 float x264_pixel_ssim_end4_neon( int sum0[5][4], int sum1[5][4], int width );
 
+#define x264_pixel_asd8_neon x264_template(pixel_asd8_neon)
 int x264_pixel_asd8_neon( uint8_t *, intptr_t,  uint8_t *, intptr_t, int );
 
 #endif
index 34b81ebb914f32096a08ce27f63455ab95ae5568..06b117f0a8eaa53a9a049e5ea26743edd2f5c953 100644 (file)
 #include "predict.h"
 #include "pixel.h"
 
-void x264_predict_4x4_dc_top_neon( uint8_t *src );
-void x264_predict_4x4_ddr_neon( uint8_t *src );
-void x264_predict_4x4_ddl_neon( uint8_t *src );
-
-void x264_predict_8x8c_dc_top_neon( uint8_t *src );
-void x264_predict_8x8c_dc_left_neon( uint8_t *src );
-void x264_predict_8x8c_p_neon( uint8_t *src );
-
-void x264_predict_8x16c_dc_left_neon( uint8_t *src );
-void x264_predict_8x16c_dc_top_neon( uint8_t *src );
-void x264_predict_8x16c_p_neon( uint8_t *src );
-
-void x264_predict_8x8_ddl_neon( uint8_t *src, uint8_t edge[36] );
-void x264_predict_8x8_ddr_neon( uint8_t *src, uint8_t edge[36] );
-void x264_predict_8x8_vl_neon( uint8_t *src, uint8_t edge[36] );
-void x264_predict_8x8_vr_neon( uint8_t *src, uint8_t edge[36] );
-void x264_predict_8x8_hd_neon( uint8_t *src, uint8_t edge[36] );
-void x264_predict_8x8_hu_neon( uint8_t *src, uint8_t edge[36] );
-
-void x264_predict_16x16_dc_top_neon( uint8_t *src );
-void x264_predict_16x16_dc_left_neon( uint8_t *src );
-void x264_predict_16x16_p_neon( uint8_t *src );
-
 void x264_predict_4x4_init_aarch64( int cpu, x264_predict_t pf[12] )
 {
 #if !HIGH_BIT_DEPTH
index a8beada056c56ce2ea681c8a88bf3bc5aec4c14c..403e9f352ff3ea7af2155c0ba37734a859854aab 100644 (file)
 #ifndef X264_AARCH64_PREDICT_H
 #define X264_AARCH64_PREDICT_H
 
+#define x264_predict_4x4_h_aarch64 x264_template(predict_4x4_h_aarch64)
 void x264_predict_4x4_h_aarch64( uint8_t *src );
+#define x264_predict_4x4_v_aarch64 x264_template(predict_4x4_v_aarch64)
 void x264_predict_4x4_v_aarch64( uint8_t *src );
+#define x264_predict_8x8c_v_aarch64 x264_template(predict_8x8c_v_aarch64)
 void x264_predict_8x8c_v_aarch64( uint8_t *src );
 
 // for the merged 4x4 intra sad/satd which expects unified suffix
@@ -36,23 +39,81 @@ void x264_predict_8x8c_v_aarch64( uint8_t *src );
 #define x264_predict_4x4_v_neon x264_predict_4x4_v_aarch64
 #define x264_predict_8x8c_v_neon x264_predict_8x8c_v_aarch64
 
+#define x264_predict_4x4_dc_top_neon x264_template(predict_4x4_dc_top_neon)
+void x264_predict_4x4_dc_top_neon( uint8_t *src );
+#define x264_predict_4x4_ddr_neon x264_template(predict_4x4_ddr_neon)
+void x264_predict_4x4_ddr_neon( uint8_t *src );
+#define x264_predict_4x4_ddl_neon x264_template(predict_4x4_ddl_neon)
+void x264_predict_4x4_ddl_neon( uint8_t *src );
+
+#define x264_predict_8x8c_dc_top_neon x264_template(predict_8x8c_dc_top_neon)
+void x264_predict_8x8c_dc_top_neon( uint8_t *src );
+#define x264_predict_8x8c_dc_left_neon x264_template(predict_8x8c_dc_left_neon)
+void x264_predict_8x8c_dc_left_neon( uint8_t *src );
+#define x264_predict_8x8c_p_neon x264_template(predict_8x8c_p_neon)
+void x264_predict_8x8c_p_neon( uint8_t *src );
+
+#define x264_predict_8x16c_dc_left_neon x264_template(predict_8x16c_dc_left_neon)
+void x264_predict_8x16c_dc_left_neon( uint8_t *src );
+#define x264_predict_8x16c_dc_top_neon x264_template(predict_8x16c_dc_top_neon)
+void x264_predict_8x16c_dc_top_neon( uint8_t *src );
+#define x264_predict_8x16c_p_neon x264_template(predict_8x16c_p_neon)
+void x264_predict_8x16c_p_neon( uint8_t *src );
+
+#define x264_predict_8x8_ddl_neon x264_template(predict_8x8_ddl_neon)
+void x264_predict_8x8_ddl_neon( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_ddr_neon x264_template(predict_8x8_ddr_neon)
+void x264_predict_8x8_ddr_neon( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_vl_neon x264_template(predict_8x8_vl_neon)
+void x264_predict_8x8_vl_neon( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_vr_neon x264_template(predict_8x8_vr_neon)
+void x264_predict_8x8_vr_neon( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_hd_neon x264_template(predict_8x8_hd_neon)
+void x264_predict_8x8_hd_neon( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_hu_neon x264_template(predict_8x8_hu_neon)
+void x264_predict_8x8_hu_neon( uint8_t *src, uint8_t edge[36] );
+
+#define x264_predict_16x16_dc_top_neon x264_template(predict_16x16_dc_top_neon)
+void x264_predict_16x16_dc_top_neon( uint8_t *src );
+#define x264_predict_16x16_dc_left_neon x264_template(predict_16x16_dc_left_neon)
+void x264_predict_16x16_dc_left_neon( uint8_t *src );
+#define x264_predict_16x16_p_neon x264_template(predict_16x16_p_neon)
+void x264_predict_16x16_p_neon( uint8_t *src );
+
+#define x264_predict_4x4_dc_neon x264_template(predict_4x4_dc_neon)
 void x264_predict_4x4_dc_neon( uint8_t *src );
+#define x264_predict_8x8_v_neon x264_template(predict_8x8_v_neon)
 void x264_predict_8x8_v_neon( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_h_neon x264_template(predict_8x8_h_neon)
 void x264_predict_8x8_h_neon( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_dc_neon x264_template(predict_8x8_dc_neon)
 void x264_predict_8x8_dc_neon( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8c_dc_neon x264_template(predict_8x8c_dc_neon)
 void x264_predict_8x8c_dc_neon( uint8_t *src );
+#define x264_predict_8x8c_h_neon x264_template(predict_8x8c_h_neon)
 void x264_predict_8x8c_h_neon( uint8_t *src );
+#define x264_predict_8x16c_v_neon x264_template(predict_8x16c_v_neon)
 void x264_predict_8x16c_v_neon( uint8_t *src );
+#define x264_predict_8x16c_h_neon x264_template(predict_8x16c_h_neon)
 void x264_predict_8x16c_h_neon( uint8_t *src );
+#define x264_predict_8x16c_dc_neon x264_template(predict_8x16c_dc_neon)
 void x264_predict_8x16c_dc_neon( uint8_t *src );
+#define x264_predict_16x16_v_neon x264_template(predict_16x16_v_neon)
 void x264_predict_16x16_v_neon( uint8_t *src );
+#define x264_predict_16x16_h_neon x264_template(predict_16x16_h_neon)
 void x264_predict_16x16_h_neon( uint8_t *src );
+#define x264_predict_16x16_dc_neon x264_template(predict_16x16_dc_neon)
 void x264_predict_16x16_dc_neon( uint8_t *src );
 
+#define x264_predict_4x4_init_aarch64 x264_template(predict_4x4_init_aarch64)
 void x264_predict_4x4_init_aarch64( int cpu, x264_predict_t pf[12] );
+#define x264_predict_8x8_init_aarch64 x264_template(predict_8x8_init_aarch64)
 void x264_predict_8x8_init_aarch64( int cpu, x264_predict8x8_t pf[12], x264_predict_8x8_filter_t *predict_filter );
+#define x264_predict_8x8c_init_aarch64 x264_template(predict_8x8c_init_aarch64)
 void x264_predict_8x8c_init_aarch64( int cpu, x264_predict_t pf[7] );
+#define x264_predict_8x16c_init_aarch64 x264_template(predict_8x16c_init_aarch64)
 void x264_predict_8x16c_init_aarch64( int cpu, x264_predict_t pf[7] );
+#define x264_predict_16x16_init_aarch64 x264_template(predict_16x16_init_aarch64)
 void x264_predict_16x16_init_aarch64( int cpu, x264_predict_t pf[7] );
 
 #endif /* X264_AARCH64_PREDICT_H */
index 266ba63472825db80e63c90298db986e31819121..1f70c77fb0b1f3e0dc388459692f5977bb668e2b 100644 (file)
@@ -305,7 +305,7 @@ endfunc
 .macro decimate_score_1x size
 function decimate_score\size\()_neon, export=1
     ld1        {v0.8h,v1.8h}, [x0]
-    movrel      x5,  X(decimate_table4)
+    movrel      x5,  X264(decimate_table4)
     movi        v3.16b, #0x01
     sqxtn       v0.8b,  v0.8h
     sqxtn2      v0.16b, v1.8h
@@ -391,7 +391,7 @@ function decimate_score64_neon, export=1
     mvn         x1,  x1
     mov         w0,  #0
     cbz         x1,  0f
-    movrel      x5,  X(decimate_table8)
+    movrel      x5,  X264(decimate_table8)
 1:
     clz         x3,  x1
     lsl         x1,  x1,  x3
index e0133e75a94f230dd3270483b2b184b1e28cebb0..72915df847b6c230b639e650f4431e45e22b5a7e 100644 (file)
 #ifndef X264_AARCH64_QUANT_H
 #define X264_AARCH64_QUANT_H
 
+#define x264_quant_2x2_dc_aarch64 x264_template(quant_2x2_dc_aarch64)
 int x264_quant_2x2_dc_aarch64( int16_t dct[4], int mf, int bias );
 
+#define x264_quant_2x2_dc_neon x264_template(quant_2x2_dc_neon)
 int x264_quant_2x2_dc_neon( int16_t dct[4], int mf, int bias );
+#define x264_quant_4x4_dc_neon x264_template(quant_4x4_dc_neon)
 int x264_quant_4x4_dc_neon( int16_t dct[16], int mf, int bias );
+#define x264_quant_4x4_neon x264_template(quant_4x4_neon)
 int x264_quant_4x4_neon( int16_t dct[16], uint16_t mf[16], uint16_t bias[16] );
+#define x264_quant_4x4x4_neon x264_template(quant_4x4x4_neon)
 int x264_quant_4x4x4_neon( int16_t dct[4][16], uint16_t mf[16], uint16_t bias[16] );
+#define x264_quant_8x8_neon x264_template(quant_8x8_neon)
 int x264_quant_8x8_neon( int16_t dct[64], uint16_t mf[64], uint16_t bias[64] );
 
+#define x264_dequant_4x4_dc_neon x264_template(dequant_4x4_dc_neon)
 void x264_dequant_4x4_dc_neon( int16_t dct[16], int dequant_mf[6][16], int i_qp );
+#define x264_dequant_4x4_neon x264_template(dequant_4x4_neon)
 void x264_dequant_4x4_neon( int16_t dct[16], int dequant_mf[6][16], int i_qp );
+#define x264_dequant_8x8_neon x264_template(dequant_8x8_neon)
 void x264_dequant_8x8_neon( int16_t dct[64], int dequant_mf[6][64], int i_qp );
 
+#define x264_decimate_score15_neon x264_template(decimate_score15_neon)
 int x264_decimate_score15_neon( int16_t * );
+#define x264_decimate_score16_neon x264_template(decimate_score16_neon)
 int x264_decimate_score16_neon( int16_t * );
+#define x264_decimate_score64_neon x264_template(decimate_score64_neon)
 int x264_decimate_score64_neon( int16_t * );
 
+#define x264_coeff_last4_aarch64 x264_template(coeff_last4_aarch64)
 int x264_coeff_last4_aarch64( int16_t * );
+#define x264_coeff_last8_aarch64 x264_template(coeff_last8_aarch64)
 int x264_coeff_last8_aarch64( int16_t * );
+#define x264_coeff_last15_neon x264_template(coeff_last15_neon)
 int x264_coeff_last15_neon( int16_t * );
+#define x264_coeff_last16_neon x264_template(coeff_last16_neon)
 int x264_coeff_last16_neon( int16_t * );
+#define x264_coeff_last64_neon x264_template(coeff_last64_neon)
 int x264_coeff_last64_neon( int16_t * );
 
+#define x264_coeff_level_run4_aarch64 x264_template(coeff_level_run4_aarch64)
 int x264_coeff_level_run4_aarch64( int16_t *, x264_run_level_t * );
+#define x264_coeff_level_run8_neon x264_template(coeff_level_run8_neon)
 int x264_coeff_level_run8_neon( int16_t *, x264_run_level_t * );
+#define x264_coeff_level_run15_neon x264_template(coeff_level_run15_neon)
 int x264_coeff_level_run15_neon( int16_t *, x264_run_level_t * );
+#define x264_coeff_level_run16_neon x264_template(coeff_level_run16_neon)
 int x264_coeff_level_run16_neon( int16_t *, x264_run_level_t * );
 
+#define x264_denoise_dct_neon x264_template(denoise_dct_neon)
 void x264_denoise_dct_neon( dctcoef *, uint32_t *, udctcoef *, int );
 
 #endif
index 5f96cdd245efb00c6f7939581404856820686e93..619a509d6da864c77a9be8cb707785cfc1f6f166 100644 (file)
 .fpu neon
 #endif
 
+#define GLUE(a, b) a ## b
+#define JOIN(a, b) GLUE(a, b)
+
 #ifdef PREFIX
-#   define EXTERN_ASM _x264_
+#   define BASE _x264_
+#   define SYM_PREFIX _
+#else
+#   define BASE x264_
+#   define SYM_PREFIX
+#endif
+
+#ifdef BIT_DEPTH
+#   define EXTERN_ASM JOIN(JOIN(BASE, BIT_DEPTH), _)
 #else
-#   define EXTERN_ASM x264_
+#   define EXTERN_ASM BASE
 #endif
 
+#define X(s) JOIN(EXTERN_ASM, s)
+#define X264(s) JOIN(BASE, s)
+#define EXT(s) JOIN(SYM_PREFIX, s)
+
 #ifdef __ELF__
 #   define ELF
 #else
@@ -173,10 +188,6 @@ MACH    .const_data
 #endif
 .endm
 
-#define GLUE(a, b) a ## b
-#define JOIN(a, b) GLUE(a, b)
-#define X(s) JOIN(EXTERN_ASM, s)
-
 #define FENC_STRIDE 16
 #define FDEC_STRIDE 32
 
diff --git a/common/arm/bitstream.h b/common/arm/bitstream.h
new file mode 100644 (file)
index 0000000..ac840ab
--- /dev/null
@@ -0,0 +1,32 @@
+/*****************************************************************************
+ * bitstream.h: arm bitstream functions
+ *****************************************************************************
+ * Copyright (C) 2017 x264 project
+ *
+ * Authors: Anton Mitrofanov <BugMaster@narod.ru>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@x264.com.
+ *****************************************************************************/
+
+#ifndef X264_ARM_BITSTREAM_H
+#define X264_ARM_BITSTREAM_H
+
+#define x264_nal_escape_neon x264_template(nal_escape_neon)
+uint8_t *x264_nal_escape_neon( uint8_t *dst, uint8_t *src, uint8_t *end );
+
+#endif
index 2b4210ab9127d467785cf185f8674079544d70e0..2af1b13e8536553d77b28562e82a62c8ff40fe77 100644 (file)
 #ifndef X264_ARM_DCT_H
 #define X264_ARM_DCT_H
 
+#define x264_dct4x4dc_neon x264_template(dct4x4dc_neon)
 void x264_dct4x4dc_neon( int16_t d[16] );
+#define x264_idct4x4dc_neon x264_template(idct4x4dc_neon)
 void x264_idct4x4dc_neon( int16_t d[16] );
 
+#define x264_sub4x4_dct_neon x264_template(sub4x4_dct_neon)
 void x264_sub4x4_dct_neon( int16_t dct[16], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub8x8_dct_neon x264_template(sub8x8_dct_neon)
 void x264_sub8x8_dct_neon( int16_t dct[4][16], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub16x16_dct_neon x264_template(sub16x16_dct_neon)
 void x264_sub16x16_dct_neon( int16_t dct[16][16], uint8_t *pix1, uint8_t *pix2 );
 
+#define x264_add4x4_idct_neon x264_template(add4x4_idct_neon)
 void x264_add4x4_idct_neon( uint8_t *p_dst, int16_t dct[16] );
+#define x264_add8x8_idct_neon x264_template(add8x8_idct_neon)
 void x264_add8x8_idct_neon( uint8_t *p_dst, int16_t dct[4][16] );
+#define x264_add16x16_idct_neon x264_template(add16x16_idct_neon)
 void x264_add16x16_idct_neon( uint8_t *p_dst, int16_t dct[16][16] );
 
+#define x264_add8x8_idct_dc_neon x264_template(add8x8_idct_dc_neon)
 void x264_add8x8_idct_dc_neon( uint8_t *p_dst, int16_t dct[4] );
+#define x264_add16x16_idct_dc_neon x264_template(add16x16_idct_dc_neon)
 void x264_add16x16_idct_dc_neon( uint8_t *p_dst, int16_t dct[16] );
+#define x264_sub8x8_dct_dc_neon x264_template(sub8x8_dct_dc_neon)
 void x264_sub8x8_dct_dc_neon( int16_t dct[4], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub8x16_dct_dc_neon x264_template(sub8x16_dct_dc_neon)
 void x264_sub8x16_dct_dc_neon( int16_t dct[8], uint8_t *pix1, uint8_t *pix2 );
 
+#define x264_sub8x8_dct8_neon x264_template(sub8x8_dct8_neon)
 void x264_sub8x8_dct8_neon( int16_t dct[64], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub16x16_dct8_neon x264_template(sub16x16_dct8_neon)
 void x264_sub16x16_dct8_neon( int16_t dct[4][64], uint8_t *pix1, uint8_t *pix2 );
 
+#define x264_add8x8_idct8_neon x264_template(add8x8_idct8_neon)
 void x264_add8x8_idct8_neon( uint8_t *p_dst, int16_t dct[64] );
+#define x264_add16x16_idct8_neon x264_template(add16x16_idct8_neon)
 void x264_add16x16_idct8_neon( uint8_t *p_dst, int16_t dct[4][64] );
 
+#define x264_zigzag_scan_4x4_frame_neon x264_template(zigzag_scan_4x4_frame_neon)
 void x264_zigzag_scan_4x4_frame_neon( int16_t level[16], int16_t dct[16] );
 
 #endif
diff --git a/common/arm/deblock.h b/common/arm/deblock.h
new file mode 100644 (file)
index 0000000..3009a9c
--- /dev/null
@@ -0,0 +1,58 @@
+/*****************************************************************************
+ * deblock.h: arm deblocking
+ *****************************************************************************
+ * Copyright (C) 2017 x264 project
+ *
+ * Authors: Anton Mitrofanov <BugMaster@narod.ru>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@x264.com.
+ *****************************************************************************/
+
+#ifndef X264_ARM_DEBLOCK_H
+#define X264_ARM_DEBLOCK_H
+
+#define x264_deblock_v_luma_neon x264_template(deblock_v_luma_neon)
+void x264_deblock_v_luma_neon  ( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_h_luma_neon x264_template(deblock_h_luma_neon)
+void x264_deblock_h_luma_neon  ( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_v_chroma_neon x264_template(deblock_v_chroma_neon)
+void x264_deblock_v_chroma_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_h_chroma_neon x264_template(deblock_h_chroma_neon)
+void x264_deblock_h_chroma_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_strength_neon x264_template(deblock_strength_neon)
+void x264_deblock_strength_neon( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE],
+                                 int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][8][4],
+                                 int mvy_limit, int bframe );
+#define x264_deblock_h_chroma_422_neon x264_template(deblock_h_chroma_422_neon)
+void x264_deblock_h_chroma_422_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_h_chroma_mbaff_neon x264_template(deblock_h_chroma_mbaff_neon)
+void x264_deblock_h_chroma_mbaff_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_h_chroma_intra_mbaff_neon x264_template(deblock_h_chroma_intra_mbaff_neon)
+void x264_deblock_h_chroma_intra_mbaff_neon( uint8_t *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_h_chroma_intra_neon x264_template(deblock_h_chroma_intra_neon)
+void x264_deblock_h_chroma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_h_chroma_422_intra_neon x264_template(deblock_h_chroma_422_intra_neon)
+void x264_deblock_h_chroma_422_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_v_chroma_intra_neon x264_template(deblock_v_chroma_intra_neon)
+void x264_deblock_v_chroma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_h_luma_intra_neon x264_template(deblock_h_luma_intra_neon)
+void x264_deblock_h_luma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_v_luma_intra_neon x264_template(deblock_v_luma_intra_neon)
+void x264_deblock_v_luma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta );
+
+#endif
index 7fe9f273a2d221ef9a905b919c4236e4584b592d..4bf420c906f091366d7f9c1f379ac9545860e462 100644 (file)
 #include "common/common.h"
 #include "mc.h"
 
+#define x264_prefetch_ref_arm x264_template(prefetch_ref_arm)
 void x264_prefetch_ref_arm( uint8_t *, intptr_t, int );
+#define x264_prefetch_fenc_arm x264_template(prefetch_fenc_arm)
 void x264_prefetch_fenc_arm( uint8_t *, intptr_t, uint8_t *, intptr_t, int );
 
+#define x264_memcpy_aligned_neon x264_template(memcpy_aligned_neon)
 void *x264_memcpy_aligned_neon( void *dst, const void *src, size_t n );
+#define x264_memzero_aligned_neon x264_template(memzero_aligned_neon)
 void x264_memzero_aligned_neon( void *dst, size_t n );
 
+#define x264_pixel_avg_16x16_neon x264_template(pixel_avg_16x16_neon)
 void x264_pixel_avg_16x16_neon( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, intptr_t, int );
+#define x264_pixel_avg_16x8_neon x264_template(pixel_avg_16x8_neon)
 void x264_pixel_avg_16x8_neon ( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, intptr_t, int );
+#define x264_pixel_avg_8x16_neon x264_template(pixel_avg_8x16_neon)
 void x264_pixel_avg_8x16_neon ( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, intptr_t, int );
+#define x264_pixel_avg_8x8_neon x264_template(pixel_avg_8x8_neon)
 void x264_pixel_avg_8x8_neon  ( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, intptr_t, int );
+#define x264_pixel_avg_8x4_neon x264_template(pixel_avg_8x4_neon)
 void x264_pixel_avg_8x4_neon  ( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, intptr_t, int );
+#define x264_pixel_avg_4x16_neon x264_template(pixel_avg_4x16_neon)
 void x264_pixel_avg_4x16_neon ( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, intptr_t, int );
+#define x264_pixel_avg_4x8_neon x264_template(pixel_avg_4x8_neon)
 void x264_pixel_avg_4x8_neon  ( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, intptr_t, int );
+#define x264_pixel_avg_4x4_neon x264_template(pixel_avg_4x4_neon)
 void x264_pixel_avg_4x4_neon  ( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, intptr_t, int );
+#define x264_pixel_avg_4x2_neon x264_template(pixel_avg_4x2_neon)
 void x264_pixel_avg_4x2_neon  ( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, intptr_t, int );
 
+#define x264_pixel_avg2_w4_neon x264_template(pixel_avg2_w4_neon)
 void x264_pixel_avg2_w4_neon ( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, int );
+#define x264_pixel_avg2_w8_neon x264_template(pixel_avg2_w8_neon)
 void x264_pixel_avg2_w8_neon ( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, int );
+#define x264_pixel_avg2_w16_neon x264_template(pixel_avg2_w16_neon)
 void x264_pixel_avg2_w16_neon( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, int );
+#define x264_pixel_avg2_w20_neon x264_template(pixel_avg2_w20_neon)
 void x264_pixel_avg2_w20_neon( uint8_t *, intptr_t, uint8_t *, intptr_t, uint8_t *, int );
 
+#define x264_plane_copy_core_neon x264_template(plane_copy_core_neon)
 void x264_plane_copy_core_neon( pixel *dst, intptr_t i_dst,
                                 pixel *src, intptr_t i_src, int w, int h );
+#define x264_plane_copy_deinterleave_neon x264_template(plane_copy_deinterleave_neon)
 void x264_plane_copy_deinterleave_neon(  pixel *dstu, intptr_t i_dstu,
                                          pixel *dstv, intptr_t i_dstv,
                                          pixel *src,  intptr_t i_src, int w, int h );
+#define x264_plane_copy_deinterleave_rgb_neon x264_template(plane_copy_deinterleave_rgb_neon)
 void x264_plane_copy_deinterleave_rgb_neon( pixel *dsta, intptr_t i_dsta,
                                             pixel *dstb, intptr_t i_dstb,
                                             pixel *dstc, intptr_t i_dstc,
                                             pixel *src,  intptr_t i_src, int pw, int w, int h );
+#define x264_plane_copy_interleave_core_neon x264_template(plane_copy_interleave_core_neon)
 void x264_plane_copy_interleave_core_neon( pixel *dst,  intptr_t i_dst,
                                            pixel *srcu, intptr_t i_srcu,
                                            pixel *srcv, intptr_t i_srcv, int w, int h );
+#define x264_plane_copy_swap_core_neon x264_template(plane_copy_swap_core_neon)
 void x264_plane_copy_swap_core_neon( pixel *dst, intptr_t i_dst,
                                      pixel *src, intptr_t i_src, int w, int h );
 
+#define x264_store_interleave_chroma_neon x264_template(store_interleave_chroma_neon)
 void x264_store_interleave_chroma_neon( pixel *dst, intptr_t i_dst, pixel *srcu, pixel *srcv, int height );
+#define x264_load_deinterleave_chroma_fdec_neon x264_template(load_deinterleave_chroma_fdec_neon)
 void x264_load_deinterleave_chroma_fdec_neon( pixel *dst, pixel *src, intptr_t i_src, int height );
+#define x264_load_deinterleave_chroma_fenc_neon x264_template(load_deinterleave_chroma_fenc_neon)
 void x264_load_deinterleave_chroma_fenc_neon( pixel *dst, pixel *src, intptr_t i_src, int height );
 
+#define x264_mc_weight_w16_neon x264_template(mc_weight_w16_neon)
+#define x264_mc_weight_w16_nodenom_neon x264_template(mc_weight_w16_nodenom_neon)
+#define x264_mc_weight_w16_offsetadd_neon x264_template(mc_weight_w16_offsetadd_neon)
+#define x264_mc_weight_w16_offsetsub_neon x264_template(mc_weight_w16_offsetsub_neon)
+#define x264_mc_weight_w20_neon x264_template(mc_weight_w20_neon)
+#define x264_mc_weight_w20_nodenom_neon x264_template(mc_weight_w20_nodenom_neon)
+#define x264_mc_weight_w20_offsetadd_neon x264_template(mc_weight_w20_offsetadd_neon)
+#define x264_mc_weight_w20_offsetsub_neon x264_template(mc_weight_w20_offsetsub_neon)
+#define x264_mc_weight_w4_neon x264_template(mc_weight_w4_neon)
+#define x264_mc_weight_w4_nodenom_neon x264_template(mc_weight_w4_nodenom_neon)
+#define x264_mc_weight_w4_offsetadd_neon x264_template(mc_weight_w4_offsetadd_neon)
+#define x264_mc_weight_w4_offsetsub_neon x264_template(mc_weight_w4_offsetsub_neon)
+#define x264_mc_weight_w8_neon x264_template(mc_weight_w8_neon)
+#define x264_mc_weight_w8_nodenom_neon x264_template(mc_weight_w8_nodenom_neon)
+#define x264_mc_weight_w8_offsetadd_neon x264_template(mc_weight_w8_offsetadd_neon)
+#define x264_mc_weight_w8_offsetsub_neon x264_template(mc_weight_w8_offsetsub_neon)
 #if !HIGH_BIT_DEPTH
 #define MC_WEIGHT(func)\
 void x264_mc_weight_w20##func##_neon( uint8_t *, intptr_t, uint8_t *, intptr_t, const x264_weight_t *, int );\
@@ -90,26 +131,42 @@ MC_WEIGHT(_offsetadd)
 MC_WEIGHT(_offsetsub)
 #endif
 
+#define x264_mc_copy_w4_neon x264_template(mc_copy_w4_neon)
 void x264_mc_copy_w4_neon ( uint8_t *, intptr_t, uint8_t *, intptr_t, int );
+#define x264_mc_copy_w8_neon x264_template(mc_copy_w8_neon)
 void x264_mc_copy_w8_neon ( uint8_t *, intptr_t, uint8_t *, intptr_t, int );
+#define x264_mc_copy_w16_neon x264_template(mc_copy_w16_neon)
 void x264_mc_copy_w16_neon( uint8_t *, intptr_t, uint8_t *, intptr_t, int );
+#define x264_mc_copy_w16_aligned_neon x264_template(mc_copy_w16_aligned_neon)
 void x264_mc_copy_w16_aligned_neon( uint8_t *, intptr_t, uint8_t *, intptr_t, int );
 
+#define x264_mc_chroma_neon x264_template(mc_chroma_neon)
 void x264_mc_chroma_neon( uint8_t *, uint8_t *, intptr_t, uint8_t *, intptr_t, int, int, int, int );
+#define x264_frame_init_lowres_core_neon x264_template(frame_init_lowres_core_neon)
 void x264_frame_init_lowres_core_neon( uint8_t *, uint8_t *, uint8_t *, uint8_t *, uint8_t *, intptr_t, intptr_t, int, int );
 
+#define x264_hpel_filter_v_neon x264_template(hpel_filter_v_neon)
 void x264_hpel_filter_v_neon( uint8_t *, uint8_t *, int16_t *, intptr_t, int );
+#define x264_hpel_filter_c_neon x264_template(hpel_filter_c_neon)
 void x264_hpel_filter_c_neon( uint8_t *, int16_t *, int );
+#define x264_hpel_filter_h_neon x264_template(hpel_filter_h_neon)
 void x264_hpel_filter_h_neon( uint8_t *, uint8_t *, int );
 
+#define x264_integral_init4h_neon x264_template(integral_init4h_neon)
 void x264_integral_init4h_neon( uint16_t *, uint8_t *, intptr_t );
+#define x264_integral_init4v_neon x264_template(integral_init4v_neon)
 void x264_integral_init4v_neon( uint16_t *, uint16_t *, intptr_t );
+#define x264_integral_init8h_neon x264_template(integral_init8h_neon)
 void x264_integral_init8h_neon( uint16_t *, uint8_t *, intptr_t );
+#define x264_integral_init8v_neon x264_template(integral_init8v_neon)
 void x264_integral_init8v_neon( uint16_t *, intptr_t );
 
+#define x264_mbtree_propagate_cost_neon x264_template(mbtree_propagate_cost_neon)
 void x264_mbtree_propagate_cost_neon( int16_t *, uint16_t *, uint16_t *, uint16_t *, uint16_t *, float *, int );
 
+#define x264_mbtree_fix8_pack_neon x264_template(mbtree_fix8_pack_neon)
 void x264_mbtree_fix8_pack_neon( uint16_t *dst, float *src, int count );
+#define x264_mbtree_fix8_unpack_neon x264_template(mbtree_fix8_unpack_neon)
 void x264_mbtree_fix8_unpack_neon( float *dst, uint16_t *src, int count );
 
 #if !HIGH_BIT_DEPTH
@@ -236,9 +293,8 @@ static void hpel_filter_neon( uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, uint8
 PLANE_COPY(16, neon)
 PLANE_COPY_SWAP(16, neon)
 PLANE_INTERLEAVE(neon)
-#endif // !HIGH_BIT_DEPTH
-
 PROPAGATE_LIST(neon)
+#endif // !HIGH_BIT_DEPTH
 
 void x264_mc_init_arm( int cpu, x264_mc_functions_t *pf )
 {
index fc8802f737697c503f9f6badd8690753d9f33629..6ea7877908b70458a5f0809192674e0e16d88463 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef X264_ARM_MC_H
 #define X264_ARM_MC_H
 
+#define x264_mc_init_arm x264_template(mc_init_arm)
 void x264_mc_init_arm( int cpu, x264_mc_functions_t *pf );
 
 #endif
index d9b02c4cedefd512276bd47eee62d31d01c67957..a87f2c41d46f254eaaf824c9fd523ff559284363 100644 (file)
 #ifndef X264_ARM_PIXEL_H
 #define X264_ARM_PIXEL_H
 
+#define x264_pixel_avg2_w16_neon x264_template(pixel_avg2_w16_neon)
+#define x264_pixel_avg2_w20_neon x264_template(pixel_avg2_w20_neon)
+#define x264_pixel_avg2_w4_neon x264_template(pixel_avg2_w4_neon)
+#define x264_pixel_avg2_w8_neon x264_template(pixel_avg2_w8_neon)
+#define x264_pixel_avg_16x16_neon x264_template(pixel_avg_16x16_neon)
+#define x264_pixel_avg_16x8_neon x264_template(pixel_avg_16x8_neon)
+#define x264_pixel_avg_4x16_neon x264_template(pixel_avg_4x16_neon)
+#define x264_pixel_avg_4x2_neon x264_template(pixel_avg_4x2_neon)
+#define x264_pixel_avg_4x4_neon x264_template(pixel_avg_4x4_neon)
+#define x264_pixel_avg_4x8_neon x264_template(pixel_avg_4x8_neon)
+#define x264_pixel_avg_8x16_neon x264_template(pixel_avg_8x16_neon)
+#define x264_pixel_avg_8x4_neon x264_template(pixel_avg_8x4_neon)
+#define x264_pixel_avg_8x8_neon x264_template(pixel_avg_8x8_neon)
+#define x264_pixel_sad_16x16_neon x264_template(pixel_sad_16x16_neon)
+#define x264_pixel_sad_16x8_neon x264_template(pixel_sad_16x8_neon)
+#define x264_pixel_sad_4x4_armv6 x264_template(pixel_sad_4x4_armv6)
+#define x264_pixel_sad_4x4_neon x264_template(pixel_sad_4x4_neon)
+#define x264_pixel_sad_4x8_armv6 x264_template(pixel_sad_4x8_armv6)
+#define x264_pixel_sad_4x8_neon x264_template(pixel_sad_4x8_neon)
+#define x264_pixel_sad_8x16_neon x264_template(pixel_sad_8x16_neon)
+#define x264_pixel_sad_8x4_neon x264_template(pixel_sad_8x4_neon)
+#define x264_pixel_sad_8x8_neon x264_template(pixel_sad_8x8_neon)
+#define x264_pixel_sad_aligned_16x16_neon x264_template(pixel_sad_aligned_16x16_neon)
+#define x264_pixel_sad_aligned_16x16_neon_dual x264_template(pixel_sad_aligned_16x16_neon_dual)
+#define x264_pixel_sad_aligned_16x8_neon x264_template(pixel_sad_aligned_16x8_neon)
+#define x264_pixel_sad_aligned_16x8_neon_dual x264_template(pixel_sad_aligned_16x8_neon_dual)
+#define x264_pixel_sad_aligned_4x4_neon x264_template(pixel_sad_aligned_4x4_neon)
+#define x264_pixel_sad_aligned_4x8_neon x264_template(pixel_sad_aligned_4x8_neon)
+#define x264_pixel_sad_aligned_8x16_neon x264_template(pixel_sad_aligned_8x16_neon)
+#define x264_pixel_sad_aligned_8x16_neon_dual x264_template(pixel_sad_aligned_8x16_neon_dual)
+#define x264_pixel_sad_aligned_8x4_neon x264_template(pixel_sad_aligned_8x4_neon)
+#define x264_pixel_sad_aligned_8x4_neon_dual x264_template(pixel_sad_aligned_8x4_neon_dual)
+#define x264_pixel_sad_aligned_8x8_neon x264_template(pixel_sad_aligned_8x8_neon)
+#define x264_pixel_sad_aligned_8x8_neon_dual x264_template(pixel_sad_aligned_8x8_neon_dual)
+#define x264_pixel_sad_x3_16x16_neon x264_template(pixel_sad_x3_16x16_neon)
+#define x264_pixel_sad_x3_16x8_neon x264_template(pixel_sad_x3_16x8_neon)
+#define x264_pixel_sad_x3_4x4_neon x264_template(pixel_sad_x3_4x4_neon)
+#define x264_pixel_sad_x3_4x8_neon x264_template(pixel_sad_x3_4x8_neon)
+#define x264_pixel_sad_x3_8x16_neon x264_template(pixel_sad_x3_8x16_neon)
+#define x264_pixel_sad_x3_8x4_neon x264_template(pixel_sad_x3_8x4_neon)
+#define x264_pixel_sad_x3_8x8_neon x264_template(pixel_sad_x3_8x8_neon)
+#define x264_pixel_sad_x4_16x16_neon x264_template(pixel_sad_x4_16x16_neon)
+#define x264_pixel_sad_x4_16x8_neon x264_template(pixel_sad_x4_16x8_neon)
+#define x264_pixel_sad_x4_4x4_neon x264_template(pixel_sad_x4_4x4_neon)
+#define x264_pixel_sad_x4_4x8_neon x264_template(pixel_sad_x4_4x8_neon)
+#define x264_pixel_sad_x4_8x16_neon x264_template(pixel_sad_x4_8x16_neon)
+#define x264_pixel_sad_x4_8x4_neon x264_template(pixel_sad_x4_8x4_neon)
+#define x264_pixel_sad_x4_8x8_neon x264_template(pixel_sad_x4_8x8_neon)
+#define x264_pixel_satd_16x16_neon x264_template(pixel_satd_16x16_neon)
+#define x264_pixel_satd_16x8_neon x264_template(pixel_satd_16x8_neon)
+#define x264_pixel_satd_4x4_neon x264_template(pixel_satd_4x4_neon)
+#define x264_pixel_satd_4x8_neon x264_template(pixel_satd_4x8_neon)
+#define x264_pixel_satd_8x16_neon x264_template(pixel_satd_8x16_neon)
+#define x264_pixel_satd_8x4_neon x264_template(pixel_satd_8x4_neon)
+#define x264_pixel_satd_8x8_neon x264_template(pixel_satd_8x8_neon)
+#define x264_pixel_ssd_16x16_neon x264_template(pixel_ssd_16x16_neon)
+#define x264_pixel_ssd_16x8_neon x264_template(pixel_ssd_16x8_neon)
+#define x264_pixel_ssd_4x4_neon x264_template(pixel_ssd_4x4_neon)
+#define x264_pixel_ssd_4x8_neon x264_template(pixel_ssd_4x8_neon)
+#define x264_pixel_ssd_8x16_neon x264_template(pixel_ssd_8x16_neon)
+#define x264_pixel_ssd_8x4_neon x264_template(pixel_ssd_8x4_neon)
+#define x264_pixel_ssd_8x8_neon x264_template(pixel_ssd_8x8_neon)
 #define DECL_PIXELS( ret, name, suffix, args ) \
     ret x264_pixel_##name##_16x16_##suffix args;\
     ret x264_pixel_##name##_16x8_##suffix args;\
@@ -52,30 +114,47 @@ DECL_X4( sad, neon )
 DECL_X1( satd, neon )
 DECL_X1( ssd, neon )
 
+#define x264_pixel_ssd_nv12_core_neon x264_template(pixel_ssd_nv12_core_neon)
 void x264_pixel_ssd_nv12_core_neon( uint8_t *, intptr_t, uint8_t *, intptr_t, int, int, uint64_t *, uint64_t * );
 
+#define x264_pixel_vsad_neon x264_template(pixel_vsad_neon)
 int x264_pixel_vsad_neon( uint8_t *, intptr_t, int );
 
+#define x264_pixel_sa8d_8x8_neon x264_template(pixel_sa8d_8x8_neon)
 int x264_pixel_sa8d_8x8_neon  ( uint8_t *, intptr_t, uint8_t *, intptr_t );
+#define x264_pixel_sa8d_16x16_neon x264_template(pixel_sa8d_16x16_neon)
 int x264_pixel_sa8d_16x16_neon( uint8_t *, intptr_t, uint8_t *, intptr_t );
+#define x264_pixel_sa8d_satd_16x16_neon x264_template(pixel_sa8d_satd_16x16_neon)
 uint64_t x264_pixel_sa8d_satd_16x16_neon( uint8_t *, intptr_t, uint8_t *, intptr_t );
 
+#define x264_pixel_var_8x8_neon x264_template(pixel_var_8x8_neon)
 uint64_t x264_pixel_var_8x8_neon  ( uint8_t *, intptr_t );
+#define x264_pixel_var_8x16_neon x264_template(pixel_var_8x16_neon)
 uint64_t x264_pixel_var_8x16_neon ( uint8_t *, intptr_t );
+#define x264_pixel_var_16x16_neon x264_template(pixel_var_16x16_neon)
 uint64_t x264_pixel_var_16x16_neon( uint8_t *, intptr_t );
+#define x264_pixel_var2_8x8_neon x264_template(pixel_var2_8x8_neon)
 int x264_pixel_var2_8x8_neon ( uint8_t *, uint8_t *, int * );
+#define x264_pixel_var2_8x16_neon x264_template(pixel_var2_8x16_neon)
 int x264_pixel_var2_8x16_neon( uint8_t *, uint8_t *, int * );
 
+#define x264_pixel_hadamard_ac_8x8_neon x264_template(pixel_hadamard_ac_8x8_neon)
 uint64_t x264_pixel_hadamard_ac_8x8_neon  ( uint8_t *, intptr_t );
+#define x264_pixel_hadamard_ac_8x16_neon x264_template(pixel_hadamard_ac_8x16_neon)
 uint64_t x264_pixel_hadamard_ac_8x16_neon ( uint8_t *, intptr_t );
+#define x264_pixel_hadamard_ac_16x8_neon x264_template(pixel_hadamard_ac_16x8_neon)
 uint64_t x264_pixel_hadamard_ac_16x8_neon ( uint8_t *, intptr_t );
+#define x264_pixel_hadamard_ac_16x16_neon x264_template(pixel_hadamard_ac_16x16_neon)
 uint64_t x264_pixel_hadamard_ac_16x16_neon( uint8_t *, intptr_t );
 
+#define x264_pixel_ssim_4x4x2_core_neon x264_template(pixel_ssim_4x4x2_core_neon)
 void x264_pixel_ssim_4x4x2_core_neon( const uint8_t *, intptr_t,
                                       const uint8_t *, intptr_t,
                                       int sums[2][4] );
+#define x264_pixel_ssim_end4_neon x264_template(pixel_ssim_end4_neon)
 float x264_pixel_ssim_end4_neon( int sum0[5][4], int sum1[5][4], int width );
 
+#define x264_pixel_asd8_neon x264_template(pixel_asd8_neon)
 int x264_pixel_asd8_neon( uint8_t *, intptr_t,  uint8_t *, intptr_t, int );
 
 #endif
index 35aeaaf3b3bc2cf430ec0eace279ead60f137f1d..03e43d3bb15619b881da7b0c6bc901804bda45c9 100644 (file)
 #ifndef X264_ARM_PREDICT_H
 #define X264_ARM_PREDICT_H
 
+#define x264_predict_4x4_dc_armv6 x264_template(predict_4x4_dc_armv6)
 void x264_predict_4x4_dc_armv6( uint8_t *src );
+#define x264_predict_4x4_dc_top_neon x264_template(predict_4x4_dc_top_neon)
 void x264_predict_4x4_dc_top_neon( uint8_t *src );
+#define x264_predict_4x4_v_armv6 x264_template(predict_4x4_v_armv6)
 void x264_predict_4x4_v_armv6( uint8_t *src );
+#define x264_predict_4x4_h_armv6 x264_template(predict_4x4_h_armv6)
 void x264_predict_4x4_h_armv6( uint8_t *src );
+#define x264_predict_4x4_ddr_armv6 x264_template(predict_4x4_ddr_armv6)
 void x264_predict_4x4_ddr_armv6( uint8_t *src );
+#define x264_predict_4x4_ddl_neon x264_template(predict_4x4_ddl_neon)
 void x264_predict_4x4_ddl_neon( uint8_t *src );
 
+#define x264_predict_8x8c_dc_neon x264_template(predict_8x8c_dc_neon)
 void x264_predict_8x8c_dc_neon( uint8_t *src );
+#define x264_predict_8x8c_dc_top_neon x264_template(predict_8x8c_dc_top_neon)
 void x264_predict_8x8c_dc_top_neon( uint8_t *src );
+#define x264_predict_8x8c_dc_left_neon x264_template(predict_8x8c_dc_left_neon)
 void x264_predict_8x8c_dc_left_neon( uint8_t *src );
+#define x264_predict_8x8c_h_neon x264_template(predict_8x8c_h_neon)
 void x264_predict_8x8c_h_neon( uint8_t *src );
+#define x264_predict_8x8c_v_neon x264_template(predict_8x8c_v_neon)
 void x264_predict_8x8c_v_neon( uint8_t *src );
+#define x264_predict_8x8c_p_neon x264_template(predict_8x8c_p_neon)
 void x264_predict_8x8c_p_neon( uint8_t *src );
 
+#define x264_predict_8x16c_h_neon x264_template(predict_8x16c_h_neon)
 void x264_predict_8x16c_h_neon( uint8_t *src );
+#define x264_predict_8x16c_dc_top_neon x264_template(predict_8x16c_dc_top_neon)
 void x264_predict_8x16c_dc_top_neon( uint8_t *src );
+#define x264_predict_8x16c_p_neon x264_template(predict_8x16c_p_neon)
 void x264_predict_8x16c_p_neon( uint8_t *src );
 
+#define x264_predict_8x8_dc_neon x264_template(predict_8x8_dc_neon)
 void x264_predict_8x8_dc_neon( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_ddl_neon x264_template(predict_8x8_ddl_neon)
 void x264_predict_8x8_ddl_neon( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_ddr_neon x264_template(predict_8x8_ddr_neon)
 void x264_predict_8x8_ddr_neon( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_vl_neon x264_template(predict_8x8_vl_neon)
 void x264_predict_8x8_vl_neon( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_vr_neon x264_template(predict_8x8_vr_neon)
 void x264_predict_8x8_vr_neon( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_v_neon x264_template(predict_8x8_v_neon)
 void x264_predict_8x8_v_neon( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_h_neon x264_template(predict_8x8_h_neon)
 void x264_predict_8x8_h_neon( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_hd_neon x264_template(predict_8x8_hd_neon)
 void x264_predict_8x8_hd_neon( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_hu_neon x264_template(predict_8x8_hu_neon)
 void x264_predict_8x8_hu_neon( uint8_t *src, uint8_t edge[36] );
 
+#define x264_predict_16x16_dc_neon x264_template(predict_16x16_dc_neon)
 void x264_predict_16x16_dc_neon( uint8_t *src );
+#define x264_predict_16x16_dc_top_neon x264_template(predict_16x16_dc_top_neon)
 void x264_predict_16x16_dc_top_neon( uint8_t *src );
+#define x264_predict_16x16_dc_left_neon x264_template(predict_16x16_dc_left_neon)
 void x264_predict_16x16_dc_left_neon( uint8_t *src );
+#define x264_predict_16x16_h_neon x264_template(predict_16x16_h_neon)
 void x264_predict_16x16_h_neon( uint8_t *src );
+#define x264_predict_16x16_v_neon x264_template(predict_16x16_v_neon)
 void x264_predict_16x16_v_neon( uint8_t *src );
+#define x264_predict_16x16_p_neon x264_template(predict_16x16_p_neon)
 void x264_predict_16x16_p_neon( uint8_t *src );
 
+#define x264_predict_4x4_init_arm x264_template(predict_4x4_init_arm)
 void x264_predict_4x4_init_arm( int cpu, x264_predict_t pf[12] );
+#define x264_predict_8x8_init_arm x264_template(predict_8x8_init_arm)
 void x264_predict_8x8_init_arm( int cpu, x264_predict8x8_t pf[12], x264_predict_8x8_filter_t *predict_filter );
+#define x264_predict_8x8c_init_arm x264_template(predict_8x8c_init_arm)
 void x264_predict_8x8c_init_arm( int cpu, x264_predict_t pf[7] );
+#define x264_predict_8x16c_init_arm x264_template(predict_8x16c_init_arm)
 void x264_predict_8x16c_init_arm( int cpu, x264_predict_t pf[7] );
+#define x264_predict_16x16_init_arm x264_template(predict_16x16_init_arm)
 void x264_predict_16x16_init_arm( int cpu, x264_predict_t pf[7] );
 
 #endif
index ad715466ae515bfea83e84c812e5991b22509730..379cceaad727475f2920adb47826810bddc6dd61 100644 (file)
@@ -347,7 +347,7 @@ function decimate_score\size\()_neon
     lsr         r1,  r1,  #2
 .endif
     rbit        r1,  r1
-    movrelx     r3,  X(decimate_table4), r2
+    movrelx     r3,  X264(decimate_table4), r2
 1:
     clz         r2,  r1
     lsl         r1,  r1,  r2
@@ -416,7 +416,7 @@ function decimate_score64_neon
     mvn         r12, r12
     mov         r0,  #0
     mov         lr,  #32
-    movrelx     r3,  X(decimate_table8), r2
+    movrelx     r3,  X264(decimate_table8), r2
     beq         2f
 1:
     clz         r2,  r1
index 2c71577fafada12c27b841400d7a5f93a1148e44..367d36123485f71c6b119ca2f8ada82fc26afbcf 100644 (file)
 #ifndef X264_ARM_QUANT_H
 #define X264_ARM_QUANT_H
 
+#define x264_quant_2x2_dc_armv6 x264_template(quant_2x2_dc_armv6)
 int x264_quant_2x2_dc_armv6( int16_t dct[4], int mf, int bias );
 
+#define x264_quant_2x2_dc_neon x264_template(quant_2x2_dc_neon)
 int x264_quant_2x2_dc_neon( int16_t dct[4], int mf, int bias );
+#define x264_quant_4x4_dc_neon x264_template(quant_4x4_dc_neon)
 int x264_quant_4x4_dc_neon( int16_t dct[16], int mf, int bias );
+#define x264_quant_4x4_neon x264_template(quant_4x4_neon)
 int x264_quant_4x4_neon( int16_t dct[16], uint16_t mf[16], uint16_t bias[16] );
+#define x264_quant_4x4x4_neon x264_template(quant_4x4x4_neon)
 int x264_quant_4x4x4_neon( int16_t dct[4][16], uint16_t mf[16], uint16_t bias[16] );
+#define x264_quant_8x8_neon x264_template(quant_8x8_neon)
 int x264_quant_8x8_neon( int16_t dct[64], uint16_t mf[64], uint16_t bias[64] );
 
+#define x264_dequant_4x4_dc_neon x264_template(dequant_4x4_dc_neon)
 void x264_dequant_4x4_dc_neon( int16_t dct[16], int dequant_mf[6][16], int i_qp );
+#define x264_dequant_4x4_neon x264_template(dequant_4x4_neon)
 void x264_dequant_4x4_neon( int16_t dct[16], int dequant_mf[6][16], int i_qp );
+#define x264_dequant_8x8_neon x264_template(dequant_8x8_neon)
 void x264_dequant_8x8_neon( int16_t dct[64], int dequant_mf[6][64], int i_qp );
 
+#define x264_decimate_score15_neon x264_template(decimate_score15_neon)
 int x264_decimate_score15_neon( int16_t * );
+#define x264_decimate_score16_neon x264_template(decimate_score16_neon)
 int x264_decimate_score16_neon( int16_t * );
+#define x264_decimate_score64_neon x264_template(decimate_score64_neon)
 int x264_decimate_score64_neon( int16_t * );
 
+#define x264_coeff_last4_arm x264_template(coeff_last4_arm)
 int x264_coeff_last4_arm( int16_t * );
+#define x264_coeff_last8_arm x264_template(coeff_last8_arm)
 int x264_coeff_last8_arm( int16_t * );
+#define x264_coeff_last15_neon x264_template(coeff_last15_neon)
 int x264_coeff_last15_neon( int16_t * );
+#define x264_coeff_last16_neon x264_template(coeff_last16_neon)
 int x264_coeff_last16_neon( int16_t * );
+#define x264_coeff_last64_neon x264_template(coeff_last64_neon)
 int x264_coeff_last64_neon( int16_t * );
 
+#define x264_denoise_dct_neon x264_template(denoise_dct_neon)
 void x264_denoise_dct_neon( dctcoef *, uint32_t *, udctcoef *, int );
 
 #endif
diff --git a/common/base.c b/common/base.c
new file mode 100644 (file)
index 0000000..294c8d5
--- /dev/null
@@ -0,0 +1,1440 @@
+/*****************************************************************************
+ * base.c: misc common functions (bit depth independent)
+ *****************************************************************************
+ * Copyright (C) 2003-2017 x264 project
+ *
+ * Authors: Loren Merritt <lorenm@u.washington.edu>
+ *          Laurent Aimar <fenrir@via.ecp.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@x264.com.
+ *****************************************************************************/
+
+#include "base.h"
+
+#include <ctype.h>
+
+#if HAVE_MALLOC_H
+#include <malloc.h>
+#endif
+#if HAVE_THP
+#include <sys/mman.h>
+#endif
+
+/****************************************************************************
+ * x264_reduce_fraction:
+ ****************************************************************************/
+#define REDUCE_FRACTION( name, type )\
+void name( type *n, type *d )\
+{                   \
+    type a = *n;    \
+    type b = *d;    \
+    type c;         \
+    if( !a || !b )  \
+        return;     \
+    c = a % b;      \
+    while( c )      \
+    {               \
+        a = b;      \
+        b = c;      \
+        c = a % b;  \
+    }               \
+    *n /= b;        \
+    *d /= b;        \
+}
+
+REDUCE_FRACTION( x264_reduce_fraction  , uint32_t )
+REDUCE_FRACTION( x264_reduce_fraction64, uint64_t )
+
+/****************************************************************************
+ * x264_log:
+ ****************************************************************************/
+void x264_log_default( void *p_unused, int i_level, const char *psz_fmt, va_list arg )
+{
+    char *psz_prefix;
+    switch( i_level )
+    {
+        case X264_LOG_ERROR:
+            psz_prefix = "error";
+            break;
+        case X264_LOG_WARNING:
+            psz_prefix = "warning";
+            break;
+        case X264_LOG_INFO:
+            psz_prefix = "info";
+            break;
+        case X264_LOG_DEBUG:
+            psz_prefix = "debug";
+            break;
+        default:
+            psz_prefix = "unknown";
+            break;
+    }
+    fprintf( stderr, "x264 [%s]: ", psz_prefix );
+    x264_vfprintf( stderr, psz_fmt, arg );
+}
+
+void x264_log_internal( int i_level, const char *psz_fmt, ... )
+{
+    va_list arg;
+    va_start( arg, psz_fmt );
+    x264_log_default( NULL, i_level, psz_fmt, arg );
+    va_end( arg );
+}
+
+/****************************************************************************
+ * x264_malloc:
+ ****************************************************************************/
+void *x264_malloc( int i_size )
+{
+    uint8_t *align_buf = NULL;
+#if HAVE_MALLOC_H
+#if HAVE_THP
+#define HUGE_PAGE_SIZE 2*1024*1024
+#define HUGE_PAGE_THRESHOLD HUGE_PAGE_SIZE*7/8 /* FIXME: Is this optimal? */
+    /* Attempt to allocate huge pages to reduce TLB misses. */
+    if( i_size >= HUGE_PAGE_THRESHOLD )
+    {
+        align_buf = memalign( HUGE_PAGE_SIZE, i_size );
+        if( align_buf )
+        {
+            /* Round up to the next huge page boundary if we are close enough. */
+            size_t madv_size = (i_size + HUGE_PAGE_SIZE - HUGE_PAGE_THRESHOLD) & ~(HUGE_PAGE_SIZE-1);
+            madvise( align_buf, madv_size, MADV_HUGEPAGE );
+        }
+    }
+    else
+#undef HUGE_PAGE_SIZE
+#undef HUGE_PAGE_THRESHOLD
+#endif
+        align_buf = memalign( NATIVE_ALIGN, i_size );
+#else
+    uint8_t *buf = malloc( i_size + (NATIVE_ALIGN-1) + sizeof(void **) );
+    if( buf )
+    {
+        align_buf = buf + (NATIVE_ALIGN-1) + sizeof(void **);
+        align_buf -= (intptr_t) align_buf & (NATIVE_ALIGN-1);
+        *( (void **) ( align_buf - sizeof(void **) ) ) = buf;
+    }
+#endif
+    if( !align_buf )
+        x264_log_internal( X264_LOG_ERROR, "malloc of size %d failed\n", i_size );
+    return align_buf;
+}
+
+/****************************************************************************
+ * x264_free:
+ ****************************************************************************/
+void x264_free( void *p )
+{
+    if( p )
+    {
+#if HAVE_MALLOC_H
+        free( p );
+#else
+        free( *( ( ( void **) p ) - 1 ) );
+#endif
+    }
+}
+
+/****************************************************************************
+ * x264_slurp_file:
+ ****************************************************************************/
+char *x264_slurp_file( const char *filename )
+{
+    int b_error = 0;
+    int64_t i_size;
+    char *buf;
+    FILE *fh = x264_fopen( filename, "rb" );
+    if( !fh )
+        return NULL;
+
+    b_error |= fseek( fh, 0, SEEK_END ) < 0;
+    b_error |= ( i_size = ftell( fh ) ) <= 0;
+    if( WORD_SIZE == 4 )
+        b_error |= i_size > INT32_MAX;
+    b_error |= fseek( fh, 0, SEEK_SET ) < 0;
+    if( b_error )
+        goto error;
+
+    buf = x264_malloc( i_size+2 );
+    if( !buf )
+        goto error;
+
+    b_error |= fread( buf, 1, i_size, fh ) != i_size;
+    fclose( fh );
+    if( b_error )
+    {
+        x264_free( buf );
+        return NULL;
+    }
+
+    if( buf[i_size-1] != '\n' )
+        buf[i_size++] = '\n';
+    buf[i_size] = '\0';
+
+    return buf;
+error:
+    fclose( fh );
+    return NULL;
+}
+
+/****************************************************************************
+ * x264_picture_init:
+ ****************************************************************************/
+void x264_picture_init( x264_picture_t *pic )
+{
+    memset( pic, 0, sizeof( x264_picture_t ) );
+    pic->i_type = X264_TYPE_AUTO;
+    pic->i_qpplus1 = X264_QP_AUTO;
+    pic->i_pic_struct = PIC_STRUCT_AUTO;
+}
+
+/****************************************************************************
+ * x264_picture_alloc:
+ ****************************************************************************/
+int x264_picture_alloc( x264_picture_t *pic, int i_csp, int i_width, int i_height )
+{
+    typedef struct
+    {
+        int planes;
+        int width_fix8[3];
+        int height_fix8[3];
+    } x264_csp_tab_t;
+
+    static const x264_csp_tab_t csp_tab[] =
+    {
+        [X264_CSP_I420] = { 3, { 256*1, 256/2, 256/2 }, { 256*1, 256/2, 256/2 } },
+        [X264_CSP_YV12] = { 3, { 256*1, 256/2, 256/2 }, { 256*1, 256/2, 256/2 } },
+        [X264_CSP_NV12] = { 2, { 256*1, 256*1 },        { 256*1, 256/2 },       },
+        [X264_CSP_NV21] = { 2, { 256*1, 256*1 },        { 256*1, 256/2 },       },
+        [X264_CSP_I422] = { 3, { 256*1, 256/2, 256/2 }, { 256*1, 256*1, 256*1 } },
+        [X264_CSP_YV16] = { 3, { 256*1, 256/2, 256/2 }, { 256*1, 256*1, 256*1 } },
+        [X264_CSP_NV16] = { 2, { 256*1, 256*1 },        { 256*1, 256*1 },       },
+        [X264_CSP_YUYV] = { 1, { 256*2 },               { 256*1 },              },
+        [X264_CSP_UYVY] = { 1, { 256*2 },               { 256*1 },              },
+        [X264_CSP_I444] = { 3, { 256*1, 256*1, 256*1 }, { 256*1, 256*1, 256*1 } },
+        [X264_CSP_YV24] = { 3, { 256*1, 256*1, 256*1 }, { 256*1, 256*1, 256*1 } },
+        [X264_CSP_BGR]  = { 1, { 256*3 },               { 256*1 },              },
+        [X264_CSP_BGRA] = { 1, { 256*4 },               { 256*1 },              },
+        [X264_CSP_RGB]  = { 1, { 256*3 },               { 256*1 },              },
+    };
+
+    int csp = i_csp & X264_CSP_MASK;
+    if( csp <= X264_CSP_NONE || csp >= X264_CSP_MAX || csp == X264_CSP_V210 )
+        return -1;
+    x264_picture_init( pic );
+    pic->img.i_csp = i_csp;
+    pic->img.i_plane = csp_tab[csp].planes;
+    int depth_factor = i_csp & X264_CSP_HIGH_DEPTH ? 2 : 1;
+    int plane_offset[3] = {0};
+    int frame_size = 0;
+    for( int i = 0; i < pic->img.i_plane; i++ )
+    {
+        int stride = (((int64_t)i_width * csp_tab[csp].width_fix8[i]) >> 8) * depth_factor;
+        int plane_size = (((int64_t)i_height * csp_tab[csp].height_fix8[i]) >> 8) * stride;
+        pic->img.i_stride[i] = stride;
+        plane_offset[i] = frame_size;
+        frame_size += plane_size;
+    }
+    pic->img.plane[0] = x264_malloc( frame_size );
+    if( !pic->img.plane[0] )
+        return -1;
+    for( int i = 1; i < pic->img.i_plane; i++ )
+        pic->img.plane[i] = pic->img.plane[0] + plane_offset[i];
+    return 0;
+}
+
+/****************************************************************************
+ * x264_picture_clean:
+ ****************************************************************************/
+void x264_picture_clean( x264_picture_t *pic )
+{
+    x264_free( pic->img.plane[0] );
+
+    /* just to be safe */
+    memset( pic, 0, sizeof( x264_picture_t ) );
+}
+
+/****************************************************************************
+ * x264_param_default:
+ ****************************************************************************/
+void x264_param_default( x264_param_t *param )
+{
+    /* */
+    memset( param, 0, sizeof( x264_param_t ) );
+
+    /* CPU autodetect */
+    param->cpu = x264_cpu_detect();
+    param->i_threads = X264_THREADS_AUTO;
+    param->i_lookahead_threads = X264_THREADS_AUTO;
+    param->b_deterministic = 1;
+    param->i_sync_lookahead = X264_SYNC_LOOKAHEAD_AUTO;
+
+    /* Video properties */
+    param->i_csp           = X264_CHROMA_FORMAT ? X264_CHROMA_FORMAT : X264_CSP_I420;
+    param->i_width         = 0;
+    param->i_height        = 0;
+    param->vui.i_sar_width = 0;
+    param->vui.i_sar_height= 0;
+    param->vui.i_overscan  = 0;  /* undef */
+    param->vui.i_vidformat = 5;  /* undef */
+    param->vui.b_fullrange = -1; /* default depends on input */
+    param->vui.i_colorprim = 2;  /* undef */
+    param->vui.i_transfer  = 2;  /* undef */
+    param->vui.i_colmatrix = -1; /* default depends on input */
+    param->vui.i_chroma_loc= 0;  /* left center */
+    param->i_fps_num       = 25;
+    param->i_fps_den       = 1;
+    param->i_level_idc     = -1;
+    param->i_slice_max_size = 0;
+    param->i_slice_max_mbs = 0;
+    param->i_slice_count = 0;
+#if HAVE_BITDEPTH8
+    param->i_bitdepth = 8;
+#elif HAVE_BITDEPTH10
+    param->i_bitdepth = 10;
+#else
+    param->i_bitdepth = 8;
+#endif
+
+    /* Encoder parameters */
+    param->i_frame_reference = 3;
+    param->i_keyint_max = 250;
+    param->i_keyint_min = X264_KEYINT_MIN_AUTO;
+    param->i_bframe = 3;
+    param->i_scenecut_threshold = 40;
+    param->i_bframe_adaptive = X264_B_ADAPT_FAST;
+    param->i_bframe_bias = 0;
+    param->i_bframe_pyramid = X264_B_PYRAMID_NORMAL;
+    param->b_interlaced = 0;
+    param->b_constrained_intra = 0;
+
+    param->b_deblocking_filter = 1;
+    param->i_deblocking_filter_alphac0 = 0;
+    param->i_deblocking_filter_beta = 0;
+
+    param->b_cabac = 1;
+    param->i_cabac_init_idc = 0;
+
+    param->rc.i_rc_method = X264_RC_CRF;
+    param->rc.i_bitrate = 0;
+    param->rc.f_rate_tolerance = 1.0;
+    param->rc.i_vbv_max_bitrate = 0;
+    param->rc.i_vbv_buffer_size = 0;
+    param->rc.f_vbv_buffer_init = 0.9;
+    param->rc.i_qp_constant = -1;
+    param->rc.f_rf_constant = 23;
+    param->rc.i_qp_min = 0;
+    param->rc.i_qp_max = INT_MAX;
+    param->rc.i_qp_step = 4;
+    param->rc.f_ip_factor = 1.4;
+    param->rc.f_pb_factor = 1.3;
+    param->rc.i_aq_mode = X264_AQ_VARIANCE;
+    param->rc.f_aq_strength = 1.0;
+    param->rc.i_lookahead = 40;
+
+    param->rc.b_stat_write = 0;
+    param->rc.psz_stat_out = "x264_2pass.log";
+    param->rc.b_stat_read = 0;
+    param->rc.psz_stat_in = "x264_2pass.log";
+    param->rc.f_qcompress = 0.6;
+    param->rc.f_qblur = 0.5;
+    param->rc.f_complexity_blur = 20;
+    param->rc.i_zones = 0;
+    param->rc.b_mb_tree = 1;
+
+    /* Log */
+    param->pf_log = x264_log_default;
+    param->p_log_private = NULL;
+    param->i_log_level = X264_LOG_INFO;
+
+    /* */
+    param->analyse.intra = X264_ANALYSE_I4x4 | X264_ANALYSE_I8x8;
+    param->analyse.inter = X264_ANALYSE_I4x4 | X264_ANALYSE_I8x8
+                         | X264_ANALYSE_PSUB16x16 | X264_ANALYSE_BSUB16x16;
+    param->analyse.i_direct_mv_pred = X264_DIRECT_PRED_SPATIAL;
+    param->analyse.i_me_method = X264_ME_HEX;
+    param->analyse.f_psy_rd = 1.0;
+    param->analyse.b_psy = 1;
+    param->analyse.f_psy_trellis = 0;
+    param->analyse.i_me_range = 16;
+    param->analyse.i_subpel_refine = 7;
+    param->analyse.b_mixed_references = 1;
+    param->analyse.b_chroma_me = 1;
+    param->analyse.i_mv_range_thread = -1;
+    param->analyse.i_mv_range = -1; // set from level_idc
+    param->analyse.i_chroma_qp_offset = 0;
+    param->analyse.b_fast_pskip = 1;
+    param->analyse.b_weighted_bipred = 1;
+    param->analyse.i_weighted_pred = X264_WEIGHTP_SMART;
+    param->analyse.b_dct_decimate = 1;
+    param->analyse.b_transform_8x8 = 1;
+    param->analyse.i_trellis = 1;
+    param->analyse.i_luma_deadzone[0] = 21;
+    param->analyse.i_luma_deadzone[1] = 11;
+    param->analyse.b_psnr = 0;
+    param->analyse.b_ssim = 0;
+
+    param->i_cqm_preset = X264_CQM_FLAT;
+    memset( param->cqm_4iy, 16, sizeof( param->cqm_4iy ) );
+    memset( param->cqm_4py, 16, sizeof( param->cqm_4py ) );
+    memset( param->cqm_4ic, 16, sizeof( param->cqm_4ic ) );
+    memset( param->cqm_4pc, 16, sizeof( param->cqm_4pc ) );
+    memset( param->cqm_8iy, 16, sizeof( param->cqm_8iy ) );
+    memset( param->cqm_8py, 16, sizeof( param->cqm_8py ) );
+    memset( param->cqm_8ic, 16, sizeof( param->cqm_8ic ) );
+    memset( param->cqm_8pc, 16, sizeof( param->cqm_8pc ) );
+
+    param->b_repeat_headers = 1;
+    param->b_annexb = 1;
+    param->b_aud = 0;
+    param->b_vfr_input = 1;
+    param->i_nal_hrd = X264_NAL_HRD_NONE;
+    param->b_tff = 1;
+    param->b_pic_struct = 0;
+    param->b_fake_interlaced = 0;
+    param->i_frame_packing = -1;
+    param->b_opencl = 0;
+    param->i_opencl_device = 0;
+    param->opencl_device_id = NULL;
+    param->psz_clbin_file = NULL;
+}
+
+static int param_apply_preset( x264_param_t *param, const char *preset )
+{
+    char *end;
+    int i = strtol( preset, &end, 10 );
+    if( *end == 0 && i >= 0 && i < sizeof(x264_preset_names)/sizeof(*x264_preset_names)-1 )
+        preset = x264_preset_names[i];
+
+    if( !strcasecmp( preset, "ultrafast" ) )
+    {
+        param->i_frame_reference = 1;
+        param->i_scenecut_threshold = 0;
+        param->b_deblocking_filter = 0;
+        param->b_cabac = 0;
+        param->i_bframe = 0;
+        param->analyse.intra = 0;
+        param->analyse.inter = 0;
+        param->analyse.b_transform_8x8 = 0;
+        param->analyse.i_me_method = X264_ME_DIA;
+        param->analyse.i_subpel_refine = 0;
+        param->rc.i_aq_mode = 0;
+        param->analyse.b_mixed_references = 0;
+        param->i_bframe_adaptive = X264_B_ADAPT_NONE;
+        param->rc.b_mb_tree = 0;
+        param->analyse.i_weighted_pred = X264_WEIGHTP_NONE;
+        param->analyse.b_weighted_bipred = 0;
+        param->rc.i_lookahead = 0;
+    }
+    else if( !strcasecmp( preset, "superfast" ) )
+    {
+        param->analyse.inter = X264_ANALYSE_I8x8|X264_ANALYSE_I4x4;
+        param->analyse.i_me_method = X264_ME_DIA;
+        param->analyse.i_subpel_refine = 1;
+        param->i_frame_reference = 1;
+        param->analyse.b_mixed_references = 0;
+        param->analyse.i_trellis = 0;
+        param->rc.b_mb_tree = 0;
+        param->analyse.i_weighted_pred = X264_WEIGHTP_SIMPLE;
+        param->rc.i_lookahead = 0;
+    }
+    else if( !strcasecmp( preset, "veryfast" ) )
+    {
+        param->analyse.i_subpel_refine = 2;
+        param->i_frame_reference = 1;
+        param->analyse.b_mixed_references = 0;
+        param->analyse.i_trellis = 0;
+        param->analyse.i_weighted_pred = X264_WEIGHTP_SIMPLE;
+        param->rc.i_lookahead = 10;
+    }
+    else if( !strcasecmp( preset, "faster" ) )
+    {
+        param->analyse.b_mixed_references = 0;
+        param->i_frame_reference = 2;
+        param->analyse.i_subpel_refine = 4;
+        param->analyse.i_weighted_pred = X264_WEIGHTP_SIMPLE;
+        param->rc.i_lookahead = 20;
+    }
+    else if( !strcasecmp( preset, "fast" ) )
+    {
+        param->i_frame_reference = 2;
+        param->analyse.i_subpel_refine = 6;
+        param->analyse.i_weighted_pred = X264_WEIGHTP_SIMPLE;
+        param->rc.i_lookahead = 30;
+    }
+    else if( !strcasecmp( preset, "medium" ) )
+    {
+        /* Default is medium */
+    }
+    else if( !strcasecmp( preset, "slow" ) )
+    {
+        param->analyse.i_subpel_refine = 8;
+        param->i_frame_reference = 5;
+        param->analyse.i_direct_mv_pred = X264_DIRECT_PRED_AUTO;
+        param->analyse.i_trellis = 2;
+        param->rc.i_lookahead = 50;
+    }
+    else if( !strcasecmp( preset, "slower" ) )
+    {
+        param->analyse.i_me_method = X264_ME_UMH;
+        param->analyse.i_subpel_refine = 9;
+        param->i_frame_reference = 8;
+        param->i_bframe_adaptive = X264_B_ADAPT_TRELLIS;
+        param->analyse.i_direct_mv_pred = X264_DIRECT_PRED_AUTO;
+        param->analyse.inter |= X264_ANALYSE_PSUB8x8;
+        param->analyse.i_trellis = 2;
+        param->rc.i_lookahead = 60;
+    }
+    else if( !strcasecmp( preset, "veryslow" ) )
+    {
+        param->analyse.i_me_method = X264_ME_UMH;
+        param->analyse.i_subpel_refine = 10;
+        param->analyse.i_me_range = 24;
+        param->i_frame_reference = 16;
+        param->i_bframe_adaptive = X264_B_ADAPT_TRELLIS;
+        param->analyse.i_direct_mv_pred = X264_DIRECT_PRED_AUTO;
+        param->analyse.inter |= X264_ANALYSE_PSUB8x8;
+        param->analyse.i_trellis = 2;
+        param->i_bframe = 8;
+        param->rc.i_lookahead = 60;
+    }
+    else if( !strcasecmp( preset, "placebo" ) )
+    {
+        param->analyse.i_me_method = X264_ME_TESA;
+        param->analyse.i_subpel_refine = 11;
+        param->analyse.i_me_range = 24;
+        param->i_frame_reference = 16;
+        param->i_bframe_adaptive = X264_B_ADAPT_TRELLIS;
+        param->analyse.i_direct_mv_pred = X264_DIRECT_PRED_AUTO;
+        param->analyse.inter |= X264_ANALYSE_PSUB8x8;
+        param->analyse.b_fast_pskip = 0;
+        param->analyse.i_trellis = 2;
+        param->i_bframe = 16;
+        param->rc.i_lookahead = 60;
+    }
+    else
+    {
+        x264_log_internal( X264_LOG_ERROR, "invalid preset '%s'\n", preset );
+        return -1;
+    }
+    return 0;
+}
+
+static int param_apply_tune( x264_param_t *param, const char *tune )
+{
+    char *tmp = x264_malloc( strlen( tune ) + 1 );
+    if( !tmp )
+        return -1;
+    tmp = strcpy( tmp, tune );
+    char *s = strtok( tmp, ",./-+" );
+    int psy_tuning_used = 0;
+    while( s )
+    {
+        if( !strncasecmp( s, "film", 4 ) )
+        {
+            if( psy_tuning_used++ ) goto psy_failure;
+            param->i_deblocking_filter_alphac0 = -1;
+            param->i_deblocking_filter_beta = -1;
+            param->analyse.f_psy_trellis = 0.15;
+        }
+        else if( !strncasecmp( s, "animation", 9 ) )
+        {
+            if( psy_tuning_used++ ) goto psy_failure;
+            param->i_frame_reference = param->i_frame_reference > 1 ? param->i_frame_reference*2 : 1;
+            param->i_deblocking_filter_alphac0 = 1;
+            param->i_deblocking_filter_beta = 1;
+            param->analyse.f_psy_rd = 0.4;
+            param->rc.f_aq_strength = 0.6;
+            param->i_bframe += 2;
+        }
+        else if( !strncasecmp( s, "grain", 5 ) )
+        {
+            if( psy_tuning_used++ ) goto psy_failure;
+            param->i_deblocking_filter_alphac0 = -2;
+            param->i_deblocking_filter_beta = -2;
+            param->analyse.f_psy_trellis = 0.25;
+            param->analyse.b_dct_decimate = 0;
+            param->rc.f_pb_factor = 1.1;
+            param->rc.f_ip_factor = 1.1;
+            param->rc.f_aq_strength = 0.5;
+            param->analyse.i_luma_deadzone[0] = 6;
+            param->analyse.i_luma_deadzone[1] = 6;
+            param->rc.f_qcompress = 0.8;
+        }
+        else if( !strncasecmp( s, "stillimage", 10 ) )
+        {
+            if( psy_tuning_used++ ) goto psy_failure;
+            param->i_deblocking_filter_alphac0 = -3;
+            param->i_deblocking_filter_beta = -3;
+            param->analyse.f_psy_rd = 2.0;
+            param->analyse.f_psy_trellis = 0.7;
+            param->rc.f_aq_strength = 1.2;
+        }
+        else if( !strncasecmp( s, "psnr", 4 ) )
+        {
+            if( psy_tuning_used++ ) goto psy_failure;
+            param->rc.i_aq_mode = X264_AQ_NONE;
+            param->analyse.b_psy = 0;
+        }
+        else if( !strncasecmp( s, "ssim", 4 ) )
+        {
+            if( psy_tuning_used++ ) goto psy_failure;
+            param->rc.i_aq_mode = X264_AQ_AUTOVARIANCE;
+            param->analyse.b_psy = 0;
+        }
+        else if( !strncasecmp( s, "fastdecode", 10 ) )
+        {
+            param->b_deblocking_filter = 0;
+            param->b_cabac = 0;
+            param->analyse.b_weighted_bipred = 0;
+            param->analyse.i_weighted_pred = X264_WEIGHTP_NONE;
+        }
+        else if( !strncasecmp( s, "zerolatency", 11 ) )
+        {
+            param->rc.i_lookahead = 0;
+            param->i_sync_lookahead = 0;
+            param->i_bframe = 0;
+            param->b_sliced_threads = 1;
+            param->b_vfr_input = 0;
+            param->rc.b_mb_tree = 0;
+        }
+        else if( !strncasecmp( s, "touhou", 6 ) )
+        {
+            if( psy_tuning_used++ ) goto psy_failure;
+            param->i_frame_reference = param->i_frame_reference > 1 ? param->i_frame_reference*2 : 1;
+            param->i_deblocking_filter_alphac0 = -1;
+            param->i_deblocking_filter_beta = -1;
+            param->analyse.f_psy_trellis = 0.2;
+            param->rc.f_aq_strength = 1.3;
+            if( param->analyse.inter & X264_ANALYSE_PSUB16x16 )
+                param->analyse.inter |= X264_ANALYSE_PSUB8x8;
+        }
+        else
+        {
+            x264_log_internal( X264_LOG_ERROR, "invalid tune '%s'\n", s );
+            x264_free( tmp );
+            return -1;
+        }
+        if( 0 )
+        {
+    psy_failure:
+            x264_log_internal( X264_LOG_WARNING, "only 1 psy tuning can be used: ignoring tune %s\n", s );
+        }
+        s = strtok( NULL, ",./-+" );
+    }
+    x264_free( tmp );
+    return 0;
+}
+
+int x264_param_default_preset( x264_param_t *param, const char *preset, const char *tune )
+{
+    x264_param_default( param );
+
+    if( preset && param_apply_preset( param, preset ) < 0 )
+        return -1;
+    if( tune && param_apply_tune( param, tune ) < 0 )
+        return -1;
+    return 0;
+}
+
+void x264_param_apply_fastfirstpass( x264_param_t *param )
+{
+    /* Set faster options in case of turbo firstpass. */
+    if( param->rc.b_stat_write && !param->rc.b_stat_read )
+    {
+        param->i_frame_reference = 1;
+        param->analyse.b_transform_8x8 = 0;
+        param->analyse.inter = 0;
+        param->analyse.i_me_method = X264_ME_DIA;
+        param->analyse.i_subpel_refine = X264_MIN( 2, param->analyse.i_subpel_refine );
+        param->analyse.i_trellis = 0;
+        param->analyse.b_fast_pskip = 1;
+    }
+}
+
+static int profile_string_to_int( const char *str )
+{
+    if( !strcasecmp( str, "baseline" ) )
+        return PROFILE_BASELINE;
+    if( !strcasecmp( str, "main" ) )
+        return PROFILE_MAIN;
+    if( !strcasecmp( str, "high" ) )
+        return PROFILE_HIGH;
+    if( !strcasecmp( str, "high10" ) )
+        return PROFILE_HIGH10;
+    if( !strcasecmp( str, "high422" ) )
+        return PROFILE_HIGH422;
+    if( !strcasecmp( str, "high444" ) )
+        return PROFILE_HIGH444_PREDICTIVE;
+    return -1;
+}
+
+int x264_param_apply_profile( x264_param_t *param, const char *profile )
+{
+    if( !profile )
+        return 0;
+
+    const int qp_bd_offset = 6 * (param->i_bitdepth-8);
+    int p = profile_string_to_int( profile );
+    if( p < 0 )
+    {
+        x264_log_internal( X264_LOG_ERROR, "invalid profile: %s\n", profile );
+        return -1;
+    }
+    if( p < PROFILE_HIGH444_PREDICTIVE && ((param->rc.i_rc_method == X264_RC_CQP && param->rc.i_qp_constant <= 0) ||
+        (param->rc.i_rc_method == X264_RC_CRF && (int)(param->rc.f_rf_constant + qp_bd_offset) <= 0)) )
+    {
+        x264_log_internal( X264_LOG_ERROR, "%s profile doesn't support lossless\n", profile );
+        return -1;
+    }
+    if( p < PROFILE_HIGH444_PREDICTIVE && (param->i_csp & X264_CSP_MASK) >= X264_CSP_I444 )
+    {
+        x264_log_internal( X264_LOG_ERROR, "%s profile doesn't support 4:4:4\n", profile );
+        return -1;
+    }
+    if( p < PROFILE_HIGH422 && (param->i_csp & X264_CSP_MASK) >= X264_CSP_I422 )
+    {
+        x264_log_internal( X264_LOG_ERROR, "%s profile doesn't support 4:2:2\n", profile );
+        return -1;
+    }
+    if( p < PROFILE_HIGH10 && param->i_bitdepth > 8 )
+    {
+        x264_log_internal( X264_LOG_ERROR, "%s profile doesn't support a bit depth of %d\n", profile, param->i_bitdepth );
+        return -1;
+    }
+
+    if( p == PROFILE_BASELINE )
+    {
+        param->analyse.b_transform_8x8 = 0;
+        param->b_cabac = 0;
+        param->i_cqm_preset = X264_CQM_FLAT;
+        param->psz_cqm_file = NULL;
+        param->i_bframe = 0;
+        param->analyse.i_weighted_pred = X264_WEIGHTP_NONE;
+        if( param->b_interlaced )
+        {
+            x264_log_internal( X264_LOG_ERROR, "baseline profile doesn't support interlacing\n" );
+            return -1;
+        }
+        if( param->b_fake_interlaced )
+        {
+            x264_log_internal( X264_LOG_ERROR, "baseline profile doesn't support fake interlacing\n" );
+            return -1;
+        }
+    }
+    else if( p == PROFILE_MAIN )
+    {
+        param->analyse.b_transform_8x8 = 0;
+        param->i_cqm_preset = X264_CQM_FLAT;
+        param->psz_cqm_file = NULL;
+    }
+    return 0;
+}
+
+static int parse_enum( const char *arg, const char * const *names, int *dst )
+{
+    for( int i = 0; names[i]; i++ )
+        if( !strcasecmp( arg, names[i] ) )
+        {
+            *dst = i;
+            return 0;
+        }
+    return -1;
+}
+
+static int parse_cqm( const char *str, uint8_t *cqm, int length )
+{
+    int i = 0;
+    do {
+        int coef;
+        if( !sscanf( str, "%d", &coef ) || coef < 1 || coef > 255 )
+            return -1;
+        cqm[i++] = coef;
+    } while( i < length && (str = strchr( str, ',' )) && str++ );
+    return (i == length) ? 0 : -1;
+}
+
+static int atobool_internal( const char *str, int *b_error )
+{
+    if( !strcmp(str, "1") ||
+        !strcasecmp(str, "true") ||
+        !strcasecmp(str, "yes") )
+        return 1;
+    if( !strcmp(str, "0") ||
+        !strcasecmp(str, "false") ||
+        !strcasecmp(str, "no") )
+        return 0;
+    *b_error = 1;
+    return 0;
+}
+
+static int atoi_internal( const char *str, int *b_error )
+{
+    char *end;
+    int v = strtol( str, &end, 0 );
+    if( end == str || *end != '\0' )
+        *b_error = 1;
+    return v;
+}
+
+static double atof_internal( const char *str, int *b_error )
+{
+    char *end;
+    double v = strtod( str, &end );
+    if( end == str || *end != '\0' )
+        *b_error = 1;
+    return v;
+}
+
+#define atobool(str) ( name_was_bool = 1, atobool_internal( str, &b_error ) )
+#undef atoi
+#undef atof
+#define atoi(str) atoi_internal( str, &b_error )
+#define atof(str) atof_internal( str, &b_error )
+
+int x264_param_parse( x264_param_t *p, const char *name, const char *value )
+{
+    char *name_buf = NULL;
+    int b_error = 0;
+    int errortype = X264_PARAM_BAD_VALUE;
+    int name_was_bool;
+    int value_was_null = !value;
+
+    if( !name )
+        return X264_PARAM_BAD_NAME;
+    if( !value )
+        value = "true";
+
+    if( value[0] == '=' )
+        value++;
+
+    if( strchr( name, '_' ) ) // s/_/-/g
+    {
+        char *c;
+        name_buf = strdup(name);
+        if( !name_buf )
+            return X264_PARAM_BAD_NAME;
+        while( (c = strchr( name_buf, '_' )) )
+            *c = '-';
+        name = name_buf;
+    }
+
+    if( !strncmp( name, "no", 2 ) )
+    {
+        name += 2;
+        if( name[0] == '-' )
+            name++;
+        value = atobool(value) ? "false" : "true";
+    }
+    name_was_bool = 0;
+
+#define OPT(STR) else if( !strcmp( name, STR ) )
+#define OPT2(STR0, STR1) else if( !strcmp( name, STR0 ) || !strcmp( name, STR1 ) )
+    if( 0 );
+    OPT("asm")
+    {
+        p->cpu = isdigit(value[0]) ? atoi(value) :
+                 !strcasecmp(value, "auto") || atobool(value) ? x264_cpu_detect() : 0;
+        if( b_error )
+        {
+            char *buf = strdup( value );
+            if( buf )
+            {
+                char *tok, UNUSED *saveptr=NULL, *init;
+                b_error = 0;
+                p->cpu = 0;
+                for( init=buf; (tok=strtok_r(init, ",", &saveptr)); init=NULL )
+                {
+                    int i = 0;
+                    while( x264_cpu_names[i].flags && strcasecmp(tok, x264_cpu_names[i].name) )
+                        i++;
+                    p->cpu |= x264_cpu_names[i].flags;
+                    if( !x264_cpu_names[i].flags )
+                        b_error = 1;
+                }
+                free( buf );
+                if( (p->cpu&X264_CPU_SSSE3) && !(p->cpu&X264_CPU_SSE2_IS_SLOW) )
+                    p->cpu |= X264_CPU_SSE2_IS_FAST;
+            }
+        }
+    }
+    OPT("threads")
+    {
+        if( !strcasecmp(value, "auto") )
+            p->i_threads = X264_THREADS_AUTO;
+        else
+            p->i_threads = atoi(value);
+    }
+    OPT("lookahead-threads")
+    {
+        if( !strcasecmp(value, "auto") )
+            p->i_lookahead_threads = X264_THREADS_AUTO;
+        else
+            p->i_lookahead_threads = atoi(value);
+    }
+    OPT("sliced-threads")
+        p->b_sliced_threads = atobool(value);
+    OPT("sync-lookahead")
+    {
+        if( !strcasecmp(value, "auto") )
+            p->i_sync_lookahead = X264_SYNC_LOOKAHEAD_AUTO;
+        else
+            p->i_sync_lookahead = atoi(value);
+    }
+    OPT2("deterministic", "n-deterministic")
+        p->b_deterministic = atobool(value);
+    OPT("cpu-independent")
+        p->b_cpu_independent = atobool(value);
+    OPT2("level", "level-idc")
+    {
+        if( !strcmp(value, "1b") )
+            p->i_level_idc = 9;
+        else if( atof(value) < 7 )
+            p->i_level_idc = (int)(10*atof(value)+.5);
+        else
+            p->i_level_idc = atoi(value);
+    }
+    OPT("bluray-compat")
+        p->b_bluray_compat = atobool(value);
+    OPT("avcintra-class")
+        p->i_avcintra_class = atoi(value);
+    OPT("sar")
+    {
+        b_error = ( 2 != sscanf( value, "%d:%d", &p->vui.i_sar_width, &p->vui.i_sar_height ) &&
+                    2 != sscanf( value, "%d/%d", &p->vui.i_sar_width, &p->vui.i_sar_height ) );
+    }
+    OPT("overscan")
+        b_error |= parse_enum( value, x264_overscan_names, &p->vui.i_overscan );
+    OPT("videoformat")
+        b_error |= parse_enum( value, x264_vidformat_names, &p->vui.i_vidformat );
+    OPT("fullrange")
+        b_error |= parse_enum( value, x264_fullrange_names, &p->vui.b_fullrange );
+    OPT("colorprim")
+        b_error |= parse_enum( value, x264_colorprim_names, &p->vui.i_colorprim );
+    OPT("transfer")
+        b_error |= parse_enum( value, x264_transfer_names, &p->vui.i_transfer );
+    OPT("colormatrix")
+        b_error |= parse_enum( value, x264_colmatrix_names, &p->vui.i_colmatrix );
+    OPT("chromaloc")
+    {
+        p->vui.i_chroma_loc = atoi(value);
+        b_error = ( p->vui.i_chroma_loc < 0 || p->vui.i_chroma_loc > 5 );
+    }
+    OPT("fps")
+    {
+        if( sscanf( value, "%u/%u", &p->i_fps_num, &p->i_fps_den ) != 2 )
+        {
+            double fps = atof(value);
+            if( fps > 0.0 && fps <= INT_MAX/1000.0 )
+            {
+                p->i_fps_num = (int)(fps * 1000.0 + .5);
+                p->i_fps_den = 1000;
+            }
+            else
+            {
+                p->i_fps_num = atoi(value);
+                p->i_fps_den = 1;
+            }
+        }
+    }
+    OPT2("ref", "frameref")
+        p->i_frame_reference = atoi(value);
+    OPT("dpb-size")
+        p->i_dpb_size = atoi(value);
+    OPT("keyint")
+    {
+        if( strstr( value, "infinite" ) )
+            p->i_keyint_max = X264_KEYINT_MAX_INFINITE;
+        else
+            p->i_keyint_max = atoi(value);
+    }
+    OPT2("min-keyint", "keyint-min")
+    {
+        p->i_keyint_min = atoi(value);
+        if( p->i_keyint_max < p->i_keyint_min )
+            p->i_keyint_max = p->i_keyint_min;
+    }
+    OPT("scenecut")
+    {
+        p->i_scenecut_threshold = atobool(value);
+        if( b_error || p->i_scenecut_threshold )
+        {
+            b_error = 0;
+            p->i_scenecut_threshold = atoi(value);
+        }
+    }
+    OPT("intra-refresh")
+        p->b_intra_refresh = atobool(value);
+    OPT("bframes")
+        p->i_bframe = atoi(value);
+    OPT("b-adapt")
+    {
+        p->i_bframe_adaptive = atobool(value);
+        if( b_error )
+        {
+            b_error = 0;
+            p->i_bframe_adaptive = atoi(value);
+        }
+    }
+    OPT("b-bias")
+        p->i_bframe_bias = atoi(value);
+    OPT("b-pyramid")
+    {
+        b_error |= parse_enum( value, x264_b_pyramid_names, &p->i_bframe_pyramid );
+        if( b_error )
+        {
+            b_error = 0;
+            p->i_bframe_pyramid = atoi(value);
+        }
+    }
+    OPT("open-gop")
+        p->b_open_gop = atobool(value);
+    OPT("nf")
+        p->b_deblocking_filter = !atobool(value);
+    OPT2("filter", "deblock")
+    {
+        if( 2 == sscanf( value, "%d:%d", &p->i_deblocking_filter_alphac0, &p->i_deblocking_filter_beta ) ||
+            2 == sscanf( value, "%d,%d", &p->i_deblocking_filter_alphac0, &p->i_deblocking_filter_beta ) )
+        {
+            p->b_deblocking_filter = 1;
+        }
+        else if( sscanf( value, "%d", &p->i_deblocking_filter_alphac0 ) )
+        {
+            p->b_deblocking_filter = 1;
+            p->i_deblocking_filter_beta = p->i_deblocking_filter_alphac0;
+        }
+        else
+            p->b_deblocking_filter = atobool(value);
+    }
+    OPT("slice-max-size")
+        p->i_slice_max_size = atoi(value);
+    OPT("slice-max-mbs")
+        p->i_slice_max_mbs = atoi(value);
+    OPT("slice-min-mbs")
+        p->i_slice_min_mbs = atoi(value);
+    OPT("slices")
+        p->i_slice_count = atoi(value);
+    OPT("slices-max")
+        p->i_slice_count_max = atoi(value);
+    OPT("cabac")
+        p->b_cabac = atobool(value);
+    OPT("cabac-idc")
+        p->i_cabac_init_idc = atoi(value);
+    OPT("interlaced")
+        p->b_interlaced = atobool(value);
+    OPT("tff")
+        p->b_interlaced = p->b_tff = atobool(value);
+    OPT("bff")
+    {
+        p->b_interlaced = atobool(value);
+        p->b_tff = !p->b_interlaced;
+    }
+    OPT("constrained-intra")
+        p->b_constrained_intra = atobool(value);
+    OPT("cqm")
+    {
+        if( strstr( value, "flat" ) )
+            p->i_cqm_preset = X264_CQM_FLAT;
+        else if( strstr( value, "jvt" ) )
+            p->i_cqm_preset = X264_CQM_JVT;
+        else
+            p->psz_cqm_file = strdup(value);
+    }
+    OPT("cqmfile")
+        p->psz_cqm_file = strdup(value);
+    OPT("cqm4")
+    {
+        p->i_cqm_preset = X264_CQM_CUSTOM;
+        b_error |= parse_cqm( value, p->cqm_4iy, 16 );
+        b_error |= parse_cqm( value, p->cqm_4py, 16 );
+        b_error |= parse_cqm( value, p->cqm_4ic, 16 );
+        b_error |= parse_cqm( value, p->cqm_4pc, 16 );
+    }
+    OPT("cqm8")
+    {
+        p->i_cqm_preset = X264_CQM_CUSTOM;
+        b_error |= parse_cqm( value, p->cqm_8iy, 64 );
+        b_error |= parse_cqm( value, p->cqm_8py, 64 );
+        b_error |= parse_cqm( value, p->cqm_8ic, 64 );
+        b_error |= parse_cqm( value, p->cqm_8pc, 64 );
+    }
+    OPT("cqm4i")
+    {
+        p->i_cqm_preset = X264_CQM_CUSTOM;
+        b_error |= parse_cqm( value, p->cqm_4iy, 16 );
+        b_error |= parse_cqm( value, p->cqm_4ic, 16 );
+    }
+    OPT("cqm4p")
+    {
+        p->i_cqm_preset = X264_CQM_CUSTOM;
+        b_error |= parse_cqm( value, p->cqm_4py, 16 );
+        b_error |= parse_cqm( value, p->cqm_4pc, 16 );
+    }
+    OPT("cqm4iy")
+    {
+        p->i_cqm_preset = X264_CQM_CUSTOM;
+        b_error |= parse_cqm( value, p->cqm_4iy, 16 );
+    }
+    OPT("cqm4ic")
+    {
+        p->i_cqm_preset = X264_CQM_CUSTOM;
+        b_error |= parse_cqm( value, p->cqm_4ic, 16 );
+    }
+    OPT("cqm4py")
+    {
+        p->i_cqm_preset = X264_CQM_CUSTOM;
+        b_error |= parse_cqm( value, p->cqm_4py, 16 );
+    }
+    OPT("cqm4pc")
+    {
+        p->i_cqm_preset = X264_CQM_CUSTOM;
+        b_error |= parse_cqm( value, p->cqm_4pc, 16 );
+    }
+    OPT("cqm8i")
+    {
+        p->i_cqm_preset = X264_CQM_CUSTOM;
+        b_error |= parse_cqm( value, p->cqm_8iy, 64 );
+        b_error |= parse_cqm( value, p->cqm_8ic, 64 );
+    }
+    OPT("cqm8p")
+    {
+        p->i_cqm_preset = X264_CQM_CUSTOM;
+        b_error |= parse_cqm( value, p->cqm_8py, 64 );
+        b_error |= parse_cqm( value, p->cqm_8pc, 64 );
+    }
+    OPT("log")
+        p->i_log_level = atoi(value);
+    OPT("dump-yuv")
+        p->psz_dump_yuv = strdup(value);
+    OPT2("analyse", "partitions")
+    {
+        p->analyse.inter = 0;
+        if( strstr( value, "none" ) )  p->analyse.inter =  0;
+        if( strstr( value, "all" ) )   p->analyse.inter = ~0;
+
+        if( strstr( value, "i4x4" ) )  p->analyse.inter |= X264_ANALYSE_I4x4;
+        if( strstr( value, "i8x8" ) )  p->analyse.inter |= X264_ANALYSE_I8x8;
+        if( strstr( value, "p8x8" ) )  p->analyse.inter |= X264_ANALYSE_PSUB16x16;
+        if( strstr( value, "p4x4" ) )  p->analyse.inter |= X264_ANALYSE_PSUB8x8;
+        if( strstr( value, "b8x8" ) )  p->analyse.inter |= X264_ANALYSE_BSUB16x16;
+    }
+    OPT("8x8dct")
+        p->analyse.b_transform_8x8 = atobool(value);
+    OPT2("weightb", "weight-b")
+        p->analyse.b_weighted_bipred = atobool(value);
+    OPT("weightp")
+        p->analyse.i_weighted_pred = atoi(value);
+    OPT2("direct", "direct-pred")
+        b_error |= parse_enum( value, x264_direct_pred_names, &p->analyse.i_direct_mv_pred );
+    OPT("chroma-qp-offset")
+        p->analyse.i_chroma_qp_offset = atoi(value);
+    OPT("me")
+        b_error |= parse_enum( value, x264_motion_est_names, &p->analyse.i_me_method );
+    OPT2("merange", "me-range")
+        p->analyse.i_me_range = atoi(value);
+    OPT2("mvrange", "mv-range")
+        p->analyse.i_mv_range = atoi(value);
+    OPT2("mvrange-thread", "mv-range-thread")
+        p->analyse.i_mv_range_thread = atoi(value);
+    OPT2("subme", "subq")
+        p->analyse.i_subpel_refine = atoi(value);
+    OPT("psy-rd")
+    {
+        if( 2 == sscanf( value, "%f:%f", &p->analyse.f_psy_rd, &p->analyse.f_psy_trellis ) ||
+            2 == sscanf( value, "%f,%f", &p->analyse.f_psy_rd, &p->analyse.f_psy_trellis ) ||
+            2 == sscanf( value, "%f|%f", &p->analyse.f_psy_rd, &p->analyse.f_psy_trellis ))
+        { }
+        else if( sscanf( value, "%f", &p->analyse.f_psy_rd ) )
+        {
+            p->analyse.f_psy_trellis = 0;
+        }
+        else
+        {
+            p->analyse.f_psy_rd = 0;
+            p->analyse.f_psy_trellis = 0;
+        }
+    }
+    OPT("psy")
+        p->analyse.b_psy = atobool(value);
+    OPT("chroma-me")
+        p->analyse.b_chroma_me = atobool(value);
+    OPT("mixed-refs")
+        p->analyse.b_mixed_references = atobool(value);
+    OPT("trellis")
+        p->analyse.i_trellis = atoi(value);
+    OPT("fast-pskip")
+        p->analyse.b_fast_pskip = atobool(value);
+    OPT("dct-decimate")
+        p->analyse.b_dct_decimate = atobool(value);
+    OPT("deadzone-inter")
+        p->analyse.i_luma_deadzone[0] = atoi(value);
+    OPT("deadzone-intra")
+        p->analyse.i_luma_deadzone[1] = atoi(value);
+    OPT("nr")
+        p->analyse.i_noise_reduction = atoi(value);
+    OPT("bitrate")
+    {
+        p->rc.i_bitrate = atoi(value);
+        p->rc.i_rc_method = X264_RC_ABR;
+    }
+    OPT2("qp", "qp_constant")
+    {
+        p->rc.i_qp_constant = atoi(value);
+        p->rc.i_rc_method = X264_RC_CQP;
+    }
+    OPT("crf")
+    {
+        p->rc.f_rf_constant = atof(value);
+        p->rc.i_rc_method = X264_RC_CRF;
+    }
+    OPT("crf-max")
+        p->rc.f_rf_constant_max = atof(value);
+    OPT("rc-lookahead")
+        p->rc.i_lookahead = atoi(value);
+    OPT2("qpmin", "qp-min")
+        p->rc.i_qp_min = atoi(value);
+    OPT2("qpmax", "qp-max")
+        p->rc.i_qp_max = atoi(value);
+    OPT2("qpstep", "qp-step")
+        p->rc.i_qp_step = atoi(value);
+    OPT("ratetol")
+        p->rc.f_rate_tolerance = !strncmp("inf", value, 3) ? 1e9 : atof(value);
+    OPT("vbv-maxrate")
+        p->rc.i_vbv_max_bitrate = atoi(value);
+    OPT("vbv-bufsize")
+        p->rc.i_vbv_buffer_size = atoi(value);
+    OPT("vbv-init")
+        p->rc.f_vbv_buffer_init = atof(value);
+    OPT2("ipratio", "ip-factor")
+        p->rc.f_ip_factor = atof(value);
+    OPT2("pbratio", "pb-factor")
+        p->rc.f_pb_factor = atof(value);
+    OPT("aq-mode")
+        p->rc.i_aq_mode = atoi(value);
+    OPT("aq-strength")
+        p->rc.f_aq_strength = atof(value);
+    OPT("pass")
+    {
+        int pass = x264_clip3( atoi(value), 0, 3 );
+        p->rc.b_stat_write = pass & 1;
+        p->rc.b_stat_read = pass & 2;
+    }
+    OPT("stats")
+    {
+        p->rc.psz_stat_in = strdup(value);
+        p->rc.psz_stat_out = strdup(value);
+    }
+    OPT("qcomp")
+        p->rc.f_qcompress = atof(value);
+    OPT("mbtree")
+        p->rc.b_mb_tree = atobool(value);
+    OPT("qblur")
+        p->rc.f_qblur = atof(value);
+    OPT2("cplxblur", "cplx-blur")
+        p->rc.f_complexity_blur = atof(value);
+    OPT("zones")
+        p->rc.psz_zones = strdup(value);
+    OPT("crop-rect")
+        b_error |= sscanf( value, "%u,%u,%u,%u", &p->crop_rect.i_left, &p->crop_rect.i_top,
+                                                 &p->crop_rect.i_right, &p->crop_rect.i_bottom ) != 4;
+    OPT("psnr")
+        p->analyse.b_psnr = atobool(value);
+    OPT("ssim")
+        p->analyse.b_ssim = atobool(value);
+    OPT("aud")
+        p->b_aud = atobool(value);
+    OPT("sps-id")
+        p->i_sps_id = atoi(value);
+    OPT("global-header")
+        p->b_repeat_headers = !atobool(value);
+    OPT("repeat-headers")
+        p->b_repeat_headers = atobool(value);
+    OPT("annexb")
+        p->b_annexb = atobool(value);
+    OPT("force-cfr")
+        p->b_vfr_input = !atobool(value);
+    OPT("nal-hrd")
+        b_error |= parse_enum( value, x264_nal_hrd_names, &p->i_nal_hrd );
+    OPT("filler")
+        p->rc.b_filler = atobool(value);
+    OPT("pic-struct")
+        p->b_pic_struct = atobool(value);
+    OPT("fake-interlaced")
+        p->b_fake_interlaced = atobool(value);
+    OPT("frame-packing")
+        p->i_frame_packing = atoi(value);
+    OPT("stitchable")
+        p->b_stitchable = atobool(value);
+    OPT("opencl")
+        p->b_opencl = atobool( value );
+    OPT("opencl-clbin")
+        p->psz_clbin_file = strdup( value );
+    OPT("opencl-device")
+        p->i_opencl_device = atoi( value );
+    else
+    {
+        b_error = 1;
+        errortype = X264_PARAM_BAD_NAME;
+    }
+#undef OPT
+#undef OPT2
+#undef atobool
+#undef atoi
+#undef atof
+
+    if( name_buf )
+        free( name_buf );
+
+    b_error |= value_was_null && !name_was_bool;
+    return b_error ? errortype : 0;
+}
+
+/****************************************************************************
+ * x264_param2string:
+ ****************************************************************************/
+char *x264_param2string( x264_param_t *p, int b_res )
+{
+    int len = 1000;
+    char *buf, *s;
+    if( p->rc.psz_zones )
+        len += strlen(p->rc.psz_zones);
+    buf = s = x264_malloc( len );
+    if( !buf )
+        return NULL;
+
+    if( b_res )
+    {
+        s += sprintf( s, "%dx%d ", p->i_width, p->i_height );
+        s += sprintf( s, "fps=%u/%u ", p->i_fps_num, p->i_fps_den );
+        s += sprintf( s, "timebase=%u/%u ", p->i_timebase_num, p->i_timebase_den );
+        s += sprintf( s, "bitdepth=%d ", p->i_bitdepth );
+    }
+
+    if( p->b_opencl )
+        s += sprintf( s, "opencl=%d ", p->b_opencl );
+    s += sprintf( s, "cabac=%d", p->b_cabac );
+    s += sprintf( s, " ref=%d", p->i_frame_reference );
+    s += sprintf( s, " deblock=%d:%d:%d", p->b_deblocking_filter,
+                  p->i_deblocking_filter_alphac0, p->i_deblocking_filter_beta );
+    s += sprintf( s, " analyse=%#x:%#x", p->analyse.intra, p->analyse.inter );
+    s += sprintf( s, " me=%s", x264_motion_est_names[ p->analyse.i_me_method ] );
+    s += sprintf( s, " subme=%d", p->analyse.i_subpel_refine );
+    s += sprintf( s, " psy=%d", p->analyse.b_psy );
+    if( p->analyse.b_psy )
+        s += sprintf( s, " psy_rd=%.2f:%.2f", p->analyse.f_psy_rd, p->analyse.f_psy_trellis );
+    s += sprintf( s, " mixed_ref=%d", p->analyse.b_mixed_references );
+    s += sprintf( s, " me_range=%d", p->analyse.i_me_range );
+    s += sprintf( s, " chroma_me=%d", p->analyse.b_chroma_me );
+    s += sprintf( s, " trellis=%d", p->analyse.i_trellis );
+    s += sprintf( s, " 8x8dct=%d", p->analyse.b_transform_8x8 );
+    s += sprintf( s, " cqm=%d", p->i_cqm_preset );
+    s += sprintf( s, " deadzone=%d,%d", p->analyse.i_luma_deadzone[0], p->analyse.i_luma_deadzone[1] );
+    s += sprintf( s, " fast_pskip=%d", p->analyse.b_fast_pskip );
+    s += sprintf( s, " chroma_qp_offset=%d", p->analyse.i_chroma_qp_offset );
+    s += sprintf( s, " threads=%d", p->i_threads );
+    s += sprintf( s, " lookahead_threads=%d", p->i_lookahead_threads );
+    s += sprintf( s, " sliced_threads=%d", p->b_sliced_threads );
+    if( p->i_slice_count )
+        s += sprintf( s, " slices=%d", p->i_slice_count );
+    if( p->i_slice_count_max )
+        s += sprintf( s, " slices_max=%d", p->i_slice_count_max );
+    if( p->i_slice_max_size )
+        s += sprintf( s, " slice_max_size=%d", p->i_slice_max_size );
+    if( p->i_slice_max_mbs )
+        s += sprintf( s, " slice_max_mbs=%d", p->i_slice_max_mbs );
+    if( p->i_slice_min_mbs )
+        s += sprintf( s, " slice_min_mbs=%d", p->i_slice_min_mbs );
+    s += sprintf( s, " nr=%d", p->analyse.i_noise_reduction );
+    s += sprintf( s, " decimate=%d", p->analyse.b_dct_decimate );
+    s += sprintf( s, " interlaced=%s", p->b_interlaced ? p->b_tff ? "tff" : "bff" : p->b_fake_interlaced ? "fake" : "0" );
+    s += sprintf( s, " bluray_compat=%d", p->b_bluray_compat );
+    if( p->b_stitchable )
+        s += sprintf( s, " stitchable=%d", p->b_stitchable );
+
+    s += sprintf( s, " constrained_intra=%d", p->b_constrained_intra );
+
+    s += sprintf( s, " bframes=%d", p->i_bframe );
+    if( p->i_bframe )
+    {
+        s += sprintf( s, " b_pyramid=%d b_adapt=%d b_bias=%d direct=%d weightb=%d open_gop=%d",
+                      p->i_bframe_pyramid, p->i_bframe_adaptive, p->i_bframe_bias,
+                      p->analyse.i_direct_mv_pred, p->analyse.b_weighted_bipred, p->b_open_gop );
+    }
+    s += sprintf( s, " weightp=%d", p->analyse.i_weighted_pred > 0 ? p->analyse.i_weighted_pred : 0 );
+
+    if( p->i_keyint_max == X264_KEYINT_MAX_INFINITE )
+        s += sprintf( s, " keyint=infinite" );
+    else
+        s += sprintf( s, " keyint=%d", p->i_keyint_max );
+    s += sprintf( s, " keyint_min=%d scenecut=%d intra_refresh=%d",
+                  p->i_keyint_min, p->i_scenecut_threshold, p->b_intra_refresh );
+
+    if( p->rc.b_mb_tree || p->rc.i_vbv_buffer_size )
+        s += sprintf( s, " rc_lookahead=%d", p->rc.i_lookahead );
+
+    s += sprintf( s, " rc=%s mbtree=%d", p->rc.i_rc_method == X264_RC_ABR ?
+                               ( p->rc.b_stat_read ? "2pass" : p->rc.i_vbv_max_bitrate == p->rc.i_bitrate ? "cbr" : "abr" )
+                               : p->rc.i_rc_method == X264_RC_CRF ? "crf" : "cqp", p->rc.b_mb_tree );
+    if( p->rc.i_rc_method == X264_RC_ABR || p->rc.i_rc_method == X264_RC_CRF )
+    {
+        if( p->rc.i_rc_method == X264_RC_CRF )
+            s += sprintf( s, " crf=%.1f", p->rc.f_rf_constant );
+        else
+            s += sprintf( s, " bitrate=%d ratetol=%.1f",
+                          p->rc.i_bitrate, p->rc.f_rate_tolerance );
+        s += sprintf( s, " qcomp=%.2f qpmin=%d qpmax=%d qpstep=%d",
+                      p->rc.f_qcompress, p->rc.i_qp_min, p->rc.i_qp_max, p->rc.i_qp_step );
+        if( p->rc.b_stat_read )
+            s += sprintf( s, " cplxblur=%.1f qblur=%.1f",
+                          p->rc.f_complexity_blur, p->rc.f_qblur );
+        if( p->rc.i_vbv_buffer_size )
+        {
+            s += sprintf( s, " vbv_maxrate=%d vbv_bufsize=%d",
+                          p->rc.i_vbv_max_bitrate, p->rc.i_vbv_buffer_size );
+            if( p->rc.i_rc_method == X264_RC_CRF )
+                s += sprintf( s, " crf_max=%.1f", p->rc.f_rf_constant_max );
+        }
+    }
+    else if( p->rc.i_rc_method == X264_RC_CQP )
+        s += sprintf( s, " qp=%d", p->rc.i_qp_constant );
+
+    if( p->rc.i_vbv_buffer_size )
+        s += sprintf( s, " nal_hrd=%s filler=%d", x264_nal_hrd_names[p->i_nal_hrd], p->rc.b_filler );
+    if( p->crop_rect.i_left | p->crop_rect.i_top | p->crop_rect.i_right | p->crop_rect.i_bottom )
+        s += sprintf( s, " crop_rect=%u,%u,%u,%u", p->crop_rect.i_left, p->crop_rect.i_top,
+                                                   p->crop_rect.i_right, p->crop_rect.i_bottom );
+    if( p->i_frame_packing >= 0 )
+        s += sprintf( s, " frame-packing=%d", p->i_frame_packing );
+
+    if( !(p->rc.i_rc_method == X264_RC_CQP && p->rc.i_qp_constant == 0) )
+    {
+        s += sprintf( s, " ip_ratio=%.2f", p->rc.f_ip_factor );
+        if( p->i_bframe && !p->rc.b_mb_tree )
+            s += sprintf( s, " pb_ratio=%.2f", p->rc.f_pb_factor );
+        s += sprintf( s, " aq=%d", p->rc.i_aq_mode );
+        if( p->rc.i_aq_mode )
+            s += sprintf( s, ":%.2f", p->rc.f_aq_strength );
+        if( p->rc.psz_zones )
+            s += sprintf( s, " zones=%s", p->rc.psz_zones );
+        else if( p->rc.i_zones )
+            s += sprintf( s, " zones" );
+    }
+
+    return buf;
+}
diff --git a/common/base.h b/common/base.h
new file mode 100644 (file)
index 0000000..1903b90
--- /dev/null
@@ -0,0 +1,317 @@
+/*****************************************************************************
+ * base.h: misc common functions (bit depth independent)
+ *****************************************************************************
+ * Copyright (C) 2003-2017 x264 project
+ *
+ * Authors: Laurent Aimar <fenrir@via.ecp.fr>
+ *          Loren Merritt <lorenm@u.washington.edu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@x264.com.
+ *****************************************************************************/
+
+#ifndef X264_BASE_H
+#define X264_BASE_H
+
+/****************************************************************************
+ * Macros (can be used in osdep.h)
+ ****************************************************************************/
+#define X264_MIN(a,b) ( (a)<(b) ? (a) : (b) )
+#define X264_MAX(a,b) ( (a)>(b) ? (a) : (b) )
+#define X264_MIN3(a,b,c) X264_MIN((a),X264_MIN((b),(c)))
+#define X264_MAX3(a,b,c) X264_MAX((a),X264_MAX((b),(c)))
+#define X264_MIN4(a,b,c,d) X264_MIN((a),X264_MIN3((b),(c),(d)))
+#define X264_MAX4(a,b,c,d) X264_MAX((a),X264_MAX3((b),(c),(d)))
+
+/****************************************************************************
+ * System includes
+ ****************************************************************************/
+#include "osdep.h"
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <limits.h>
+#include "x264.h"
+
+/****************************************************************************
+ * Macros
+ ****************************************************************************/
+#define XCHG(type,a,b) do { type t = a; a = b; b = t; } while( 0 )
+#define FIX8(f) ((int)(f*(1<<8)+.5))
+#define ARRAY_ELEMS(a) ((sizeof(a))/(sizeof(a[0])))
+#define ARRAY_SIZE(array) (sizeof(array)/sizeof(array[0]))
+#define ALIGN(x,a) (((x)+((a)-1))&~((a)-1))
+#define IS_DISPOSABLE(type) ( type == X264_TYPE_B )
+
+/* Unions for type-punning.
+ * Mn: load or store n bits, aligned, native-endian
+ * CPn: copy n bits, aligned, native-endian
+ * we don't use memcpy for CPn because memcpy's args aren't assumed to be aligned */
+typedef union { uint16_t i; uint8_t  c[2]; } MAY_ALIAS x264_union16_t;
+typedef union { uint32_t i; uint16_t b[2]; uint8_t  c[4]; } MAY_ALIAS x264_union32_t;
+typedef union { uint64_t i; uint32_t a[2]; uint16_t b[4]; uint8_t c[8]; } MAY_ALIAS x264_union64_t;
+typedef struct { uint64_t i[2]; } x264_uint128_t;
+typedef union { x264_uint128_t i; uint64_t a[2]; uint32_t b[4]; uint16_t c[8]; uint8_t d[16]; } MAY_ALIAS x264_union128_t;
+#define M16(src) (((x264_union16_t*)(src))->i)
+#define M32(src) (((x264_union32_t*)(src))->i)
+#define M64(src) (((x264_union64_t*)(src))->i)
+#define M128(src) (((x264_union128_t*)(src))->i)
+#define M128_ZERO ((x264_uint128_t){{0,0}})
+#define CP16(dst,src) M16(dst) = M16(src)
+#define CP32(dst,src) M32(dst) = M32(src)
+#define CP64(dst,src) M64(dst) = M64(src)
+#define CP128(dst,src) M128(dst) = M128(src)
+
+/****************************************************************************
+ * Constants
+ ****************************************************************************/
+enum profile_e
+{
+    PROFILE_BASELINE = 66,
+    PROFILE_MAIN     = 77,
+    PROFILE_HIGH    = 100,
+    PROFILE_HIGH10  = 110,
+    PROFILE_HIGH422 = 122,
+    PROFILE_HIGH444_PREDICTIVE = 244,
+};
+
+enum chroma_format_e
+{
+    CHROMA_400 = 0,
+    CHROMA_420 = 1,
+    CHROMA_422 = 2,
+    CHROMA_444 = 3,
+};
+
+enum slice_type_e
+{
+    SLICE_TYPE_P  = 0,
+    SLICE_TYPE_B  = 1,
+    SLICE_TYPE_I  = 2,
+};
+
+static const char slice_type_to_char[] = { 'P', 'B', 'I' };
+
+enum sei_payload_type_e
+{
+    SEI_BUFFERING_PERIOD       = 0,
+    SEI_PIC_TIMING             = 1,
+    SEI_PAN_SCAN_RECT          = 2,
+    SEI_FILLER                 = 3,
+    SEI_USER_DATA_REGISTERED   = 4,
+    SEI_USER_DATA_UNREGISTERED = 5,
+    SEI_RECOVERY_POINT         = 6,
+    SEI_DEC_REF_PIC_MARKING    = 7,
+    SEI_FRAME_PACKING          = 45,
+};
+
+#define X264_BFRAME_MAX 16
+#define X264_REF_MAX 16
+#define X264_THREAD_MAX 128
+#define X264_LOOKAHEAD_THREAD_MAX 16
+#define X264_LOOKAHEAD_MAX 250
+
+// number of pixels (per thread) in progress at any given time.
+// 16 for the macroblock in progress + 3 for deblocking + 3 for motion compensation filter + 2 for extra safety
+#define X264_THREAD_HEIGHT 24
+
+/* WEIGHTP_FAKE is set when mb_tree & psy are enabled, but normal weightp is disabled
+ * (such as in baseline). It checks for fades in lookahead and adjusts qp accordingly
+ * to increase quality. Defined as (-1) so that if(i_weighted_pred > 0) is true only when
+ * real weights are being used. */
+
+#define X264_WEIGHTP_FAKE (-1)
+
+#define X264_SCAN8_LUMA_SIZE (5*8)
+#define X264_SCAN8_SIZE (X264_SCAN8_LUMA_SIZE*3)
+#define X264_SCAN8_0 (4+1*8)
+
+/* Scan8 organization:
+ *    0 1 2 3 4 5 6 7
+ * 0  DY    y y y y y
+ * 1        y Y Y Y Y
+ * 2        y Y Y Y Y
+ * 3        y Y Y Y Y
+ * 4        y Y Y Y Y
+ * 5  DU    u u u u u
+ * 6        u U U U U
+ * 7        u U U U U
+ * 8        u U U U U
+ * 9        u U U U U
+ * 10 DV    v v v v v
+ * 11       v V V V V
+ * 12       v V V V V
+ * 13       v V V V V
+ * 14       v V V V V
+ * DY/DU/DV are for luma/chroma DC.
+ */
+
+#define LUMA_DC   48
+#define CHROMA_DC 49
+
+static const uint8_t x264_scan8[16*3 + 3] =
+{
+    4+ 1*8, 5+ 1*8, 4+ 2*8, 5+ 2*8,
+    6+ 1*8, 7+ 1*8, 6+ 2*8, 7+ 2*8,
+    4+ 3*8, 5+ 3*8, 4+ 4*8, 5+ 4*8,
+    6+ 3*8, 7+ 3*8, 6+ 4*8, 7+ 4*8,
+    4+ 6*8, 5+ 6*8, 4+ 7*8, 5+ 7*8,
+    6+ 6*8, 7+ 6*8, 6+ 7*8, 7+ 7*8,
+    4+ 8*8, 5+ 8*8, 4+ 9*8, 5+ 9*8,
+    6+ 8*8, 7+ 8*8, 6+ 9*8, 7+ 9*8,
+    4+11*8, 5+11*8, 4+12*8, 5+12*8,
+    6+11*8, 7+11*8, 6+12*8, 7+12*8,
+    4+13*8, 5+13*8, 4+14*8, 5+14*8,
+    6+13*8, 7+13*8, 6+14*8, 7+14*8,
+    0+ 0*8, 0+ 5*8, 0+10*8
+};
+
+/****************************************************************************
+ * Includes
+ ****************************************************************************/
+#include "cpu.h"
+#include "tables.h"
+
+/****************************************************************************
+ * Inline functions
+ ****************************************************************************/
+static ALWAYS_INLINE int x264_clip3( int v, int i_min, int i_max )
+{
+    return ( (v < i_min) ? i_min : (v > i_max) ? i_max : v );
+}
+
+static ALWAYS_INLINE double x264_clip3f( double v, double f_min, double f_max )
+{
+    return ( (v < f_min) ? f_min : (v > f_max) ? f_max : v );
+}
+
+/* Not a general-purpose function; multiplies input by -1/6 to convert
+ * qp to qscale. */
+static ALWAYS_INLINE int x264_exp2fix8( float x )
+{
+    int i = x*(-64.f/6.f) + 512.5f;
+    if( i < 0 ) return 0;
+    if( i > 1023 ) return 0xffff;
+    return (x264_exp2_lut[i&63]+256) << (i>>6) >> 8;
+}
+
+static ALWAYS_INLINE float x264_log2( uint32_t x )
+{
+    int lz = x264_clz( x );
+    return x264_log2_lut[(x<<lz>>24)&0x7f] + x264_log2_lz_lut[lz];
+}
+
+static ALWAYS_INLINE int x264_median( int a, int b, int c )
+{
+    int t = (a-b)&((a-b)>>31);
+    a -= t;
+    b += t;
+    b -= (b-c)&((b-c)>>31);
+    b += (a-b)&((a-b)>>31);
+    return b;
+}
+
+static ALWAYS_INLINE void x264_median_mv( int16_t *dst, int16_t *a, int16_t *b, int16_t *c )
+{
+    dst[0] = x264_median( a[0], b[0], c[0] );
+    dst[1] = x264_median( a[1], b[1], c[1] );
+}
+
+static ALWAYS_INLINE int x264_predictor_difference( int16_t (*mvc)[2], intptr_t i_mvc )
+{
+    int sum = 0;
+    for( int i = 0; i < i_mvc-1; i++ )
+    {
+        sum += abs( mvc[i][0] - mvc[i+1][0] )
+             + abs( mvc[i][1] - mvc[i+1][1] );
+    }
+    return sum;
+}
+
+static ALWAYS_INLINE uint16_t x264_cabac_mvd_sum( uint8_t *mvdleft, uint8_t *mvdtop )
+{
+    int amvd0 = mvdleft[0] + mvdtop[0];
+    int amvd1 = mvdleft[1] + mvdtop[1];
+    amvd0 = (amvd0 > 2) + (amvd0 > 32);
+    amvd1 = (amvd1 > 2) + (amvd1 > 32);
+    return amvd0 + (amvd1<<8);
+}
+
+/****************************************************************************
+ * General functions
+ ****************************************************************************/
+void x264_reduce_fraction( uint32_t *n, uint32_t *d );
+void x264_reduce_fraction64( uint64_t *n, uint64_t *d );
+
+void x264_log_default( void *p_unused, int i_level, const char *psz_fmt, va_list arg );
+void x264_log_internal( int i_level, const char *psz_fmt, ... );
+
+/* x264_malloc : will do or emulate a memalign
+ * you have to use x264_free for buffers allocated with x264_malloc */
+void *x264_malloc( int );
+void  x264_free( void * );
+
+/* x264_slurp_file: malloc space for the whole file and read it */
+char *x264_slurp_file( const char *filename );
+
+/* x264_param2string: return a (malloced) string containing most of
+ * the encoding options */
+char *x264_param2string( x264_param_t *p, int b_res );
+
+/****************************************************************************
+ * Macros
+ ****************************************************************************/
+#define CHECKED_MALLOC( var, size )\
+do {\
+    var = x264_malloc( size );\
+    if( !var )\
+        goto fail;\
+} while( 0 )
+#define CHECKED_MALLOCZERO( var, size )\
+do {\
+    CHECKED_MALLOC( var, size );\
+    memset( var, 0, size );\
+} while( 0 )
+
+/* Macros for merging multiple allocations into a single large malloc, for improved
+ * use with huge pages. */
+
+/* Needs to be enough to contain any set of buffers that use combined allocations */
+#define PREALLOC_BUF_SIZE 1024
+
+#define PREALLOC_INIT\
+    int    prealloc_idx = 0;\
+    size_t prealloc_size = 0;\
+    uint8_t **preallocs[PREALLOC_BUF_SIZE];
+
+#define PREALLOC( var, size )\
+do {\
+    var = (void*)prealloc_size;\
+    preallocs[prealloc_idx++] = (uint8_t**)&var;\
+    prealloc_size += ALIGN(size, NATIVE_ALIGN);\
+} while( 0 )
+
+#define PREALLOC_END( ptr )\
+do {\
+    CHECKED_MALLOC( ptr, prealloc_size );\
+    while( prealloc_idx-- )\
+        *preallocs[prealloc_idx] += (intptr_t)ptr;\
+} while( 0 )
+
+#endif
index e11d6133369a81b3d7d3ea43ab6b2187082eac3a..ef4ddacb38f6ee1de11afb2393efd0a22b1646ca 100644 (file)
@@ -39,25 +39,15 @@ static uint8_t *nal_escape_c( uint8_t *dst, uint8_t *src, uint8_t *end )
     return dst;
 }
 
-uint8_t *x264_nal_escape_mmx2( uint8_t *dst, uint8_t *src, uint8_t *end );
-uint8_t *x264_nal_escape_sse2( uint8_t *dst, uint8_t *src, uint8_t *end );
-uint8_t *x264_nal_escape_avx2( uint8_t *dst, uint8_t *src, uint8_t *end );
-void x264_cabac_block_residual_rd_internal_sse2       ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
-void x264_cabac_block_residual_rd_internal_lzcnt      ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
-void x264_cabac_block_residual_rd_internal_ssse3      ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
-void x264_cabac_block_residual_rd_internal_ssse3_lzcnt( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
-void x264_cabac_block_residual_rd_internal_avx512     ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
-void x264_cabac_block_residual_8x8_rd_internal_sse2       ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
-void x264_cabac_block_residual_8x8_rd_internal_lzcnt      ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
-void x264_cabac_block_residual_8x8_rd_internal_ssse3      ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
-void x264_cabac_block_residual_8x8_rd_internal_ssse3_lzcnt( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
-void x264_cabac_block_residual_8x8_rd_internal_avx512     ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
-void x264_cabac_block_residual_internal_sse2  ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
-void x264_cabac_block_residual_internal_lzcnt ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
-void x264_cabac_block_residual_internal_avx2  ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
-void x264_cabac_block_residual_internal_avx512( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
-
-uint8_t *x264_nal_escape_neon( uint8_t *dst, uint8_t *src, uint8_t *end );
+#if HAVE_MMX
+#include "x86/bitstream.h"
+#endif
+#if HAVE_ARMV6
+#include "arm/bitstream.h"
+#endif
+#if ARCH_AARCH64
+#include "aarch64/bitstream.h"
+#endif
 
 /****************************************************************************
  * x264_nal_encode:
index 2816ef331494402c275bbf07b2b6e22c58c47b3d..039b310a4b24d77a80520e5228c454f30339e0fe 100644 (file)
 #ifndef X264_BS_H
 #define X264_BS_H
 
-typedef struct
-{
-    uint8_t i_bits;
-    uint8_t i_size;
-} vlc_t;
-
 typedef struct
 {
     uint16_t i_bits;
@@ -60,12 +54,6 @@ typedef struct
     ALIGNED_16( dctcoef level[18] );
 } x264_run_level_t;
 
-extern const vlc_t x264_coeff0_token[6];
-extern const vlc_t x264_coeff_token[6][16][4];
-extern const vlc_t x264_total_zeros[15][16];
-extern const vlc_t x264_total_zeros_2x2_dc[3][4];
-extern const vlc_t x264_total_zeros_2x4_dc[7][8];
-
 typedef struct
 {
     uint8_t *(*nal_escape)( uint8_t *dst, uint8_t *src, uint8_t *end );
@@ -77,6 +65,7 @@ typedef struct
                                                   intptr_t ctx_block_cat, x264_cabac_t *cb );
 } x264_bitstream_function_t;
 
+#define x264_bitstream_init x264_template(bitstream_init)
 void x264_bitstream_init( int cpu, x264_bitstream_function_t *pf );
 
 /* A larger level table size theoretically could help a bit at extremely
@@ -85,11 +74,13 @@ void x264_bitstream_init( int cpu, x264_bitstream_function_t *pf );
  * This size appears to be optimal for QP18 encoding on a Nehalem CPU.
  * FIXME: Do further testing? */
 #define LEVEL_TABLE_SIZE 128
+#define x264_level_token x264_template(level_token)
 extern vlc_large_t x264_level_token[7][LEVEL_TABLE_SIZE];
 
 /* The longest possible set of zero run codes sums to 25 bits.  This leaves
  * plenty of room for both the code (25 bits) and size (5 bits) in a uint32_t. */
 
+#define x264_run_before x264_template(run_before)
 extern uint32_t x264_run_before[1<<16];
 
 static inline void bs_init( bs_t *s, void *p_data, int i_data )
index 04264ac2912787d840d0cbc3737f3cac33421f0f..429c42bfe54730df3a194f7f96af05097da7a3b5 100644 (file)
 
 #include "common.h"
 
-
-static const int8_t cabac_context_init_I[1024][2] =
-{
-    /* 0 - 10 */
-    { 20, -15 }, {  2, 54 },  {  3,  74 }, { 20, -15 },
-    {  2,  54 }, {  3, 74 },  { -28,127 }, { -23, 104 },
-    { -6,  53 }, { -1, 54 },  {  7,  51 },
-
-    /* 11 - 23 unused for I */
-    { 0, 0 },    { 0, 0 },    { 0, 0 },      { 0, 0 },
-    { 0, 0 },    { 0, 0 },    { 0, 0 },      { 0, 0 },
-    { 0, 0 },    { 0, 0 },    { 0, 0 },      { 0, 0 },
-    { 0, 0 },
-
-    /* 24- 39 */
-    { 0, 0 },    { 0, 0 },    { 0, 0 },      { 0, 0 },
-    { 0, 0 },    { 0, 0 },    { 0, 0 },      { 0, 0 },
-    { 0, 0 },    { 0, 0 },    { 0, 0 },      { 0, 0 },
-    { 0, 0 },    { 0, 0 },    { 0, 0 },      { 0, 0 },
-
-    /* 40 - 53 */
-    { 0, 0 },    { 0, 0 },    { 0, 0 },      { 0, 0 },
-    { 0, 0 },    { 0, 0 },    { 0, 0 },      { 0, 0 },
-    { 0, 0 },    { 0, 0 },    { 0, 0 },      { 0, 0 },
-    { 0, 0 },    { 0, 0 },
-
-    /* 54 - 59 */
-    { 0, 0 },    { 0, 0 },    { 0, 0 },      { 0, 0 },
-    { 0, 0 },    { 0, 0 },
-
-    /* 60 - 69 */
-    { 0, 41 },   { 0, 63 },   { 0, 63 },     { 0, 63 },
-    { -9, 83 },  { 4, 86 },   { 0, 97 },     { -7, 72 },
-    { 13, 41 },  { 3, 62 },
-
-    /* 70 -> 87 */
-    { 0, 11 },   { 1, 55 },   { 0, 69 },     { -17, 127 },
-    { -13, 102 },{ 0, 82 },   { -7, 74 },    { -21, 107 },
-    { -27, 127 },{ -31, 127 },{ -24, 127 },  { -18, 95 },
-    { -27, 127 },{ -21, 114 },{ -30, 127 },  { -17, 123 },
-    { -12, 115 },{ -16, 122 },
-
-    /* 88 -> 104 */
-    { -11, 115 },{ -12, 63 }, { -2, 68 },    { -15, 84 },
-    { -13, 104 },{ -3, 70 },  { -8, 93 },    { -10, 90 },
-    { -30, 127 },{ -1, 74 },  { -6, 97 },    { -7, 91 },
-    { -20, 127 },{ -4, 56 },  { -5, 82 },    { -7, 76 },
-    { -22, 125 },
-
-    /* 105 -> 135 */
-    { -7, 93 },  { -11, 87 }, { -3, 77 },    { -5, 71 },
-    { -4, 63 },  { -4, 68 },  { -12, 84 },   { -7, 62 },
-    { -7, 65 },  { 8, 61 },   { 5, 56 },     { -2, 66 },
-    { 1, 64 },   { 0, 61 },   { -2, 78 },    { 1, 50 },
-    { 7, 52 },   { 10, 35 },  { 0, 44 },     { 11, 38 },
-    { 1, 45 },   { 0, 46 },   { 5, 44 },     { 31, 17 },
-    { 1, 51 },   { 7, 50 },   { 28, 19 },    { 16, 33 },
-    { 14, 62 },  { -13, 108 },{ -15, 100 },
-
-    /* 136 -> 165 */
-    { -13, 101 },{ -13, 91 }, { -12, 94 },   { -10, 88 },
-    { -16, 84 }, { -10, 86 }, { -7, 83 },    { -13, 87 },
-    { -19, 94 }, { 1, 70 },   { 0, 72 },     { -5, 74 },
-    { 18, 59 },  { -8, 102 }, { -15, 100 },  { 0, 95 },
-    { -4, 75 },  { 2, 72 },   { -11, 75 },   { -3, 71 },
-    { 15, 46 },  { -13, 69 }, { 0, 62 },     { 0, 65 },
-    { 21, 37 },  { -15, 72 }, { 9, 57 },     { 16, 54 },
-    { 0, 62 },   { 12, 72 },
-
-    /* 166 -> 196 */
-    { 24, 0 },   { 15, 9 },   { 8, 25 },     { 13, 18 },
-    { 15, 9 },   { 13, 19 },  { 10, 37 },    { 12, 18 },
-    { 6, 29 },   { 20, 33 },  { 15, 30 },    { 4, 45 },
-    { 1, 58 },   { 0, 62 },   { 7, 61 },     { 12, 38 },
-    { 11, 45 },  { 15, 39 },  { 11, 42 },    { 13, 44 },
-    { 16, 45 },  { 12, 41 },  { 10, 49 },    { 30, 34 },
-    { 18, 42 },  { 10, 55 },  { 17, 51 },    { 17, 46 },
-    { 0, 89 },   { 26, -19 }, { 22, -17 },
-
-    /* 197 -> 226 */
-    { 26, -17 }, { 30, -25 }, { 28, -20 },   { 33, -23 },
-    { 37, -27 }, { 33, -23 }, { 40, -28 },   { 38, -17 },
-    { 33, -11 }, { 40, -15 }, { 41, -6 },    { 38, 1 },
-    { 41, 17 },  { 30, -6 },  { 27, 3 },     { 26, 22 },
-    { 37, -16 }, { 35, -4 },  { 38, -8 },    { 38, -3 },
-    { 37, 3 },   { 38, 5 },   { 42, 0 },     { 35, 16 },
-    { 39, 22 },  { 14, 48 },  { 27, 37 },    { 21, 60 },
-    { 12, 68 },  { 2, 97 },
-
-    /* 227 -> 251 */
-    { -3, 71 },  { -6, 42 },  { -5, 50 },    { -3, 54 },
-    { -2, 62 },  { 0, 58 },   { 1, 63 },     { -2, 72 },
-    { -1, 74 },  { -9, 91 },  { -5, 67 },    { -5, 27 },
-    { -3, 39 },  { -2, 44 },  { 0, 46 },     { -16, 64 },
-    { -8, 68 },  { -10, 78 }, { -6, 77 },    { -10, 86 },
-    { -12, 92 }, { -15, 55 }, { -10, 60 },   { -6, 62 },
-    { -4, 65 },
-
-    /* 252 -> 275 */
-    { -12, 73 }, { -8, 76 },  { -7, 80 },    { -9, 88 },
-    { -17, 110 },{ -11, 97 }, { -20, 84 },   { -11, 79 },
-    { -6, 73 },  { -4, 74 },  { -13, 86 },   { -13, 96 },
-    { -11, 97 }, { -19, 117 },{ -8, 78 },    { -5, 33 },
-    { -4, 48 },  { -2, 53 },  { -3, 62 },    { -13, 71 },
-    { -10, 79 }, { -12, 86 }, { -13, 90 },   { -14, 97 },
-
-    /* 276 a bit special (not used, x264_cabac_encode_bypass is used instead) */
-    { 0, 0 },
-
-    /* 277 -> 307 */
-    { -6, 93 },  { -6, 84 },  { -8, 79 },    { 0, 66 },
-    { -1, 71 },  { 0, 62 },   { -2, 60 },    { -2, 59 },
-    { -5, 75 },  { -3, 62 },  { -4, 58 },    { -9, 66 },
-    { -1, 79 },  { 0, 71 },   { 3, 68 },     { 10, 44 },
-    { -7, 62 },  { 15, 36 },  { 14, 40 },    { 16, 27 },
-    { 12, 29 },  { 1, 44 },   { 20, 36 },    { 18, 32 },
-    { 5, 42 },   { 1, 48 },   { 10, 62 },    { 17, 46 },
-    { 9, 64 },   { -12, 104 },{ -11, 97 },
-
-    /* 308 -> 337 */
-    { -16, 96 }, { -7, 88 },  { -8, 85 },    { -7, 85 },
-    { -9, 85 },  { -13, 88 }, { 4, 66 },     { -3, 77 },
-    { -3, 76 },  { -6, 76 },  { 10, 58 },    { -1, 76 },
-    { -1, 83 },  { -7, 99 },  { -14, 95 },   { 2, 95 },
-    { 0, 76 },   { -5, 74 },  { 0, 70 },     { -11, 75 },
-    { 1, 68 },   { 0, 65 },   { -14, 73 },   { 3, 62 },
-    { 4, 62 },   { -1, 68 },  { -13, 75 },   { 11, 55 },
-    { 5, 64 },   { 12, 70 },
-
-    /* 338 -> 368 */
-    { 15, 6 },   { 6, 19 },   { 7, 16 },     { 12, 14 },
-    { 18, 13 },  { 13, 11 },  { 13, 15 },    { 15, 16 },
-    { 12, 23 },  { 13, 23 },  { 15, 20 },    { 14, 26 },
-    { 14, 44 },  { 17, 40 },  { 17, 47 },    { 24, 17 },
-    { 21, 21 },  { 25, 22 },  { 31, 27 },    { 22, 29 },
-    { 19, 35 },  { 14, 50 },  { 10, 57 },    { 7, 63 },
-    { -2, 77 },  { -4, 82 },  { -3, 94 },    { 9, 69 },
-    { -12, 109 },{ 36, -35 }, { 36, -34 },
-
-    /* 369 -> 398 */
-    { 32, -26 }, { 37, -30 }, { 44, -32 },   { 34, -18 },
-    { 34, -15 }, { 40, -15 }, { 33, -7 },    { 35, -5 },
-    { 33, 0 },   { 38, 2 },   { 33, 13 },    { 23, 35 },
-    { 13, 58 },  { 29, -3 },  { 26, 0 },     { 22, 30 },
-    { 31, -7 },  { 35, -15 }, { 34, -3 },    { 34, 3 },
-    { 36, -1 },  { 34, 5 },   { 32, 11 },    { 35, 5 },
-    { 34, 12 },  { 39, 11 },  { 30, 29 },    { 34, 26 },
-    { 29, 39 },  { 19, 66 },
-
-    /* 399 -> 435 */
-    {  31,  21 }, {  31,  31 }, {  25,  50 },
-    { -17, 120 }, { -20, 112 }, { -18, 114 }, { -11,  85 },
-    { -15,  92 }, { -14,  89 }, { -26,  71 }, { -15,  81 },
-    { -14,  80 }, {   0,  68 }, { -14,  70 }, { -24,  56 },
-    { -23,  68 }, { -24,  50 }, { -11,  74 }, {  23, -13 },
-    {  26, -13 }, {  40, -15 }, {  49, -14 }, {  44,   3 },
-    {  45,   6 }, {  44,  34 }, {  33,  54 }, {  19,  82 },
-    {  -3,  75 }, {  -1,  23 }, {   1,  34 }, {   1,  43 },
-    {   0,  54 }, {  -2,  55 }, {   0,  61 }, {   1,  64 },
-    {   0,  68 }, {  -9,  92 },
-
-    /* 436 -> 459 */
-    { -14, 106 }, { -13,  97 }, { -15,  90 }, { -12,  90 },
-    { -18,  88 }, { -10,  73 }, {  -9,  79 }, { -14,  86 },
-    { -10,  73 }, { -10,  70 }, { -10,  69 }, {  -5,  66 },
-    {  -9,  64 }, {  -5,  58 }, {   2,  59 }, {  21, -10 },
-    {  24, -11 }, {  28,  -8 }, {  28,  -1 }, {  29,   3 },
-    {  29,   9 }, {  35,  20 }, {  29,  36 }, {  14,  67 },
-
-    /* 460 -> 1024 */
-    { -17, 123 }, { -12, 115 }, { -16, 122 }, { -11, 115 },
-    { -12,  63 }, {  -2,  68 }, { -15,  84 }, { -13, 104 },
-    {  -3,  70 }, {  -8,  93 }, { -10,  90 }, { -30, 127 },
-    { -17, 123 }, { -12, 115 }, { -16, 122 }, { -11, 115 },
-    { -12,  63 }, {  -2,  68 }, { -15,  84 }, { -13, 104 },
-    {  -3,  70 }, {  -8,  93 }, { -10,  90 }, { -30, 127 },
-    {  -7,  93 }, { -11,  87 }, {  -3,  77 }, {  -5,  71 },
-    {  -4,  63 }, {  -4,  68 }, { -12,  84 }, {  -7,  62 },
-    {  -7,  65 }, {   8,  61 }, {   5,  56 }, {  -2,  66 },
-    {   1,  64 }, {   0,  61 }, {  -2,  78 }, {   1,  50 },
-    {   7,  52 }, {  10,  35 }, {   0,  44 }, {  11,  38 },
-    {   1,  45 }, {   0,  46 }, {   5,  44 }, {  31,  17 },
-    {   1,  51 }, {   7,  50 }, {  28,  19 }, {  16,  33 },
-    {  14,  62 }, { -13, 108 }, { -15, 100 }, { -13, 101 },
-    { -13,  91 }, { -12,  94 }, { -10,  88 }, { -16,  84 },
-    { -10,  86 }, {  -7,  83 }, { -13,  87 }, { -19,  94 },
-    {   1,  70 }, {   0,  72 }, {  -5,  74 }, {  18,  59 },
-    {  -7,  93 }, { -11,  87 }, {  -3,  77 }, {  -5,  71 },
-    {  -4,  63 }, {  -4,  68 }, { -12,  84 }, {  -7,  62 },
-    {  -7,  65 }, {   8,  61 }, {   5,  56 }, {  -2,  66 },
-    {   1,  64 }, {   0,  61 }, {  -2,  78 }, {   1,  50 },
-    {   7,  52 }, {  10,  35 }, {   0,  44 }, {  11,  38 },
-    {   1,  45 }, {   0,  46 }, {   5,  44 }, {  31,  17 },
-    {   1,  51 }, {   7,  50 }, {  28,  19 }, {  16,  33 },
-    {  14,  62 }, { -13, 108 }, { -15, 100 }, { -13, 101 },
-    { -13,  91 }, { -12,  94 }, { -10,  88 }, { -16,  84 },
-    { -10,  86 }, {  -7,  83 }, { -13,  87 }, { -19,  94 },
-    {   1,  70 }, {   0,  72 }, {  -5,  74 }, {  18,  59 },
-    {  24,   0 }, {  15,   9 }, {   8,  25 }, {  13,  18 },
-    {  15,   9 }, {  13,  19 }, {  10,  37 }, {  12,  18 },
-    {   6,  29 }, {  20,  33 }, {  15,  30 }, {   4,  45 },
-    {   1,  58 }, {   0,  62 }, {   7,  61 }, {  12,  38 },
-    {  11,  45 }, {  15,  39 }, {  11,  42 }, {  13,  44 },
-    {  16,  45 }, {  12,  41 }, {  10,  49 }, {  30,  34 },
-    {  18,  42 }, {  10,  55 }, {  17,  51 }, {  17,  46 },
-    {   0,  89 }, {  26, -19 }, {  22, -17 }, {  26, -17 },
-    {  30, -25 }, {  28, -20 }, {  33, -23 }, {  37, -27 },
-    {  33, -23 }, {  40, -28 }, {  38, -17 }, {  33, -11 },
-    {  40, -15 }, {  41,  -6 }, {  38,   1 }, {  41,  17 },
-    {  24,   0 }, {  15,   9 }, {   8,  25 }, {  13,  18 },
-    {  15,   9 }, {  13,  19 }, {  10,  37 }, {  12,  18 },
-    {   6,  29 }, {  20,  33 }, {  15,  30 }, {   4,  45 },
-    {   1,  58 }, {   0,  62 }, {   7,  61 }, {  12,  38 },
-    {  11,  45 }, {  15,  39 }, {  11,  42 }, {  13,  44 },
-    {  16,  45 }, {  12,  41 }, {  10,  49 }, {  30,  34 },
-    {  18,  42 }, {  10,  55 }, {  17,  51 }, {  17,  46 },
-    {   0,  89 }, {  26, -19 }, {  22, -17 }, {  26, -17 },
-    {  30, -25 }, {  28, -20 }, {  33, -23 }, {  37, -27 },
-    {  33, -23 }, {  40, -28 }, {  38, -17 }, {  33, -11 },
-    {  40, -15 }, {  41,  -6 }, {  38,   1 }, {  41,  17 },
-    { -17, 120 }, { -20, 112 }, { -18, 114 }, { -11,  85 },
-    { -15,  92 }, { -14,  89 }, { -26,  71 }, { -15,  81 },
-    { -14,  80 }, {   0,  68 }, { -14,  70 }, { -24,  56 },
-    { -23,  68 }, { -24,  50 }, { -11,  74 }, { -14, 106 },
-    { -13,  97 }, { -15,  90 }, { -12,  90 }, { -18,  88 },
-    { -10,  73 }, {  -9,  79 }, { -14,  86 }, { -10,  73 },
-    { -10,  70 }, { -10,  69 }, {  -5,  66 }, {  -9,  64 },
-    {  -5,  58 }, {   2,  59 }, {  23, -13 }, {  26, -13 },
-    {  40, -15 }, {  49, -14 }, {  44,   3 }, {  45,   6 },
-    {  44,  34 }, {  33,  54 }, {  19,  82 }, {  21, -10 },
-    {  24, -11 }, {  28,  -8 }, {  28,  -1 }, {  29,   3 },
-    {  29,   9 }, {  35,  20 }, {  29,  36 }, {  14,  67 },
-    {  -3,  75 }, {  -1,  23 }, {   1,  34 }, {   1,  43 },
-    {   0,  54 }, {  -2,  55 }, {   0,  61 }, {   1,  64 },
-    {   0,  68 }, {  -9,  92 }, { -17, 120 }, { -20, 112 },
-    { -18, 114 }, { -11,  85 }, { -15,  92 }, { -14,  89 },
-    { -26,  71 }, { -15,  81 }, { -14,  80 }, {   0,  68 },
-    { -14,  70 }, { -24,  56 }, { -23,  68 }, { -24,  50 },
-    { -11,  74 }, { -14, 106 }, { -13,  97 }, { -15,  90 },
-    { -12,  90 }, { -18,  88 }, { -10,  73 }, {  -9,  79 },
-    { -14,  86 }, { -10,  73 }, { -10,  70 }, { -10,  69 },
-    {  -5,  66 }, {  -9,  64 }, {  -5,  58 }, {   2,  59 },
-    {  23, -13 }, {  26, -13 }, {  40, -15 }, {  49, -14 },
-    {  44,   3 }, {  45,   6 }, {  44,  34 }, {  33,  54 },
-    {  19,  82 }, {  21, -10 }, {  24, -11 }, {  28,  -8 },
-    {  28,  -1 }, {  29,   3 }, {  29,   9 }, {  35,  20 },
-    {  29,  36 }, {  14,  67 }, {  -3,  75 }, {  -1,  23 },
-    {   1,  34 }, {   1,  43 }, {   0,  54 }, {  -2,  55 },
-    {   0,  61 }, {   1,  64 }, {   0,  68 }, {  -9,  92 },
-    {  -6,  93 }, {  -6,  84 }, {  -8,  79 }, {   0,  66 },
-    {  -1,  71 }, {   0,  62 }, {  -2,  60 }, {  -2,  59 },
-    {  -5,  75 }, {  -3,  62 }, {  -4,  58 }, {  -9,  66 },
-    {  -1,  79 }, {   0,  71 }, {   3,  68 }, {  10,  44 },
-    {  -7,  62 }, {  15,  36 }, {  14,  40 }, {  16,  27 },
-    {  12,  29 }, {   1,  44 }, {  20,  36 }, {  18,  32 },
-    {   5,  42 }, {   1,  48 }, {  10,  62 }, {  17,  46 },
-    {   9,  64 }, { -12, 104 }, { -11,  97 }, { -16,  96 },
-    {  -7,  88 }, {  -8,  85 }, {  -7,  85 }, {  -9,  85 },
-    { -13,  88 }, {   4,  66 }, {  -3,  77 }, {  -3,  76 },
-    {  -6,  76 }, {  10,  58 }, {  -1,  76 }, {  -1,  83 },
-    {  -6,  93 }, {  -6,  84 }, {  -8,  79 }, {   0,  66 },
-    {  -1,  71 }, {   0,  62 }, {  -2,  60 }, {  -2,  59 },
-    {  -5,  75 }, {  -3,  62 }, {  -4,  58 }, {  -9,  66 },
-    {  -1,  79 }, {   0,  71 }, {   3,  68 }, {  10,  44 },
-    {  -7,  62 }, {  15,  36 }, {  14,  40 }, {  16,  27 },
-    {  12,  29 }, {   1,  44 }, {  20,  36 }, {  18,  32 },
-    {   5,  42 }, {   1,  48 }, {  10,  62 }, {  17,  46 },
-    {   9,  64 }, { -12, 104 }, { -11,  97 }, { -16,  96 },
-    {  -7,  88 }, {  -8,  85 }, {  -7,  85 }, {  -9,  85 },
-    { -13,  88 }, {   4,  66 }, {  -3,  77 }, {  -3,  76 },
-    {  -6,  76 }, {  10,  58 }, {  -1,  76 }, {  -1,  83 },
-    {  15,   6 }, {   6,  19 }, {   7,  16 }, {  12,  14 },
-    {  18,  13 }, {  13,  11 }, {  13,  15 }, {  15,  16 },
-    {  12,  23 }, {  13,  23 }, {  15,  20 }, {  14,  26 },
-    {  14,  44 }, {  17,  40 }, {  17,  47 }, {  24,  17 },
-    {  21,  21 }, {  25,  22 }, {  31,  27 }, {  22,  29 },
-    {  19,  35 }, {  14,  50 }, {  10,  57 }, {   7,  63 },
-    {  -2,  77 }, {  -4,  82 }, {  -3,  94 }, {   9,  69 },
-    { -12, 109 }, {  36, -35 }, {  36, -34 }, {  32, -26 },
-    {  37, -30 }, {  44, -32 }, {  34, -18 }, {  34, -15 },
-    {  40, -15 }, {  33,  -7 }, {  35,  -5 }, {  33,   0 },
-    {  38,   2 }, {  33,  13 }, {  23,  35 }, {  13,  58 },
-    {  15,   6 }, {   6,  19 }, {   7,  16 }, {  12,  14 },
-    {  18,  13 }, {  13,  11 }, {  13,  15 }, {  15,  16 },
-    {  12,  23 }, {  13,  23 }, {  15,  20 }, {  14,  26 },
-    {  14,  44 }, {  17,  40 }, {  17,  47 }, {  24,  17 },
-    {  21,  21 }, {  25,  22 }, {  31,  27 }, {  22,  29 },
-    {  19,  35 }, {  14,  50 }, {  10,  57 }, {   7,  63 },
-    {  -2,  77 }, {  -4,  82 }, {  -3,  94 }, {   9,  69 },
-    { -12, 109 }, {  36, -35 }, {  36, -34 }, {  32, -26 },
-    {  37, -30 }, {  44, -32 }, {  34, -18 }, {  34, -15 },
-    {  40, -15 }, {  33,  -7 }, {  35,  -5 }, {  33,   0 },
-    {  38,   2 }, {  33,  13 }, {  23,  35 }, {  13,  58 },
-    {  -3,  71 }, {  -6,  42 }, {  -5,  50 }, {  -3,  54 },
-    {  -2,  62 }, {   0,  58 }, {   1,  63 }, {  -2,  72 },
-    {  -1,  74 }, {  -9,  91 }, {  -5,  67 }, {  -5,  27 },
-    {  -3,  39 }, {  -2,  44 }, {   0,  46 }, { -16,  64 },
-    {  -8,  68 }, { -10,  78 }, {  -6,  77 }, { -10,  86 },
-    { -12,  92 }, { -15,  55 }, { -10,  60 }, {  -6,  62 },
-    {  -4,  65 }, { -12,  73 }, {  -8,  76 }, {  -7,  80 },
-    {  -9,  88 }, { -17, 110 }, {  -3,  71 }, {  -6,  42 },
-    {  -5,  50 }, {  -3,  54 }, {  -2,  62 }, {   0,  58 },
-    {   1,  63 }, {  -2,  72 }, {  -1,  74 }, {  -9,  91 },
-    {  -5,  67 }, {  -5,  27 }, {  -3,  39 }, {  -2,  44 },
-    {   0,  46 }, { -16,  64 }, {  -8,  68 }, { -10,  78 },
-    {  -6,  77 }, { -10,  86 }, { -12,  92 }, { -15,  55 },
-    { -10,  60 }, {  -6,  62 }, {  -4,  65 }, { -12,  73 },
-    {  -8,  76 }, {  -7,  80 }, {  -9,  88 }, { -17, 110 },
-    {  -3,  70 }, {  -8,  93 }, { -10,  90 }, { -30, 127 },
-    {  -3,  70 }, {  -8,  93 }, { -10,  90 }, { -30, 127 },
-    {  -3,  70 }, {  -8,  93 }, { -10,  90 }, { -30, 127 }
-};
-
-static const int8_t cabac_context_init_PB[3][1024][2] =
-{
-    /* i_cabac_init_idc == 0 */
-    {
-        /* 0 - 10 */
-        {  20, -15 }, {   2,  54 }, {   3,  74 }, {  20, -15 },
-        {   2,  54 }, {   3,  74 }, { -28, 127 }, { -23, 104 },
-        {  -6,  53 }, {  -1,  54 }, {   7,  51 },
-
-        /* 11 - 23 */
-        {  23,  33 }, {  23,   2 }, {  21,   0 }, {   1,   9 },
-        {   0,  49 }, { -37, 118 }, {   5,  57 }, { -13,  78 },
-        { -11,  65 }, {   1,  62 }, {  12,  49 }, {  -4,  73 },
-        {  17,  50 },
-
-        /* 24 - 39 */
-        {  18,  64 }, {   9,  43 }, {  29,   0 }, {  26,  67 },
-        {  16,  90 }, {   9, 104 }, { -46, 127 }, { -20, 104 },
-        {   1,  67 }, { -13,  78 }, { -11,  65 }, {   1,  62 },
-        {  -6,  86 }, { -17,  95 }, {  -6,  61 }, {   9,  45 },
-
-        /* 40 - 53 */
-        {  -3,  69 }, {  -6,  81 }, { -11,  96 }, {   6,  55 },
-        {   7,  67 }, {  -5,  86 }, {   2,  88 }, {   0,  58 },
-        {  -3,  76 }, { -10,  94 }, {   5,  54 }, {   4,  69 },
-        {  -3,  81 }, {   0,  88 },
-
-        /* 54 - 59 */
-        {  -7,  67 }, {  -5,  74 }, {  -4,  74 }, {  -5,  80 },
-        {  -7,  72 }, {   1,  58 },
-
-        /* 60 - 69 */
-        {   0,  41 }, {   0,  63 }, {   0,  63 }, { 0, 63 },
-        {  -9,  83 }, {   4,  86 }, {   0,  97 }, { -7, 72 },
-        {  13,  41 }, {   3,  62 },
-
-        /* 70 - 87 */
-        {   0,  45 }, {  -4,  78 }, {  -3,  96 }, { -27,  126 },
-        { -28,  98 }, { -25, 101 }, { -23,  67 }, { -28,  82 },
-        { -20,  94 }, { -16,  83 }, { -22, 110 }, { -21,  91 },
-        { -18, 102 }, { -13,  93 }, { -29, 127 }, {  -7,  92 },
-        {  -5,  89 }, {  -7,  96 }, { -13, 108 }, {  -3,  46 },
-        {  -1,  65 }, {  -1,  57 }, {  -9,  93 }, {  -3,  74 },
-        {  -9,  92 }, {  -8,  87 }, { -23, 126 }, {   5,  54 },
-        {   6,  60 }, {   6,  59 }, {   6,  69 }, {  -1,  48 },
-        {   0,  68 }, {  -4,  69 }, {  -8,  88 },
-
-        /* 105 -> 165 */
-        {  -2,  85 }, {  -6,  78 }, {  -1,  75 }, {  -7,  77 },
-        {   2,  54 }, {   5,  50 }, {  -3,  68 }, {   1,  50 },
-        {   6,  42 }, {  -4,  81 }, {   1,  63 }, {  -4,  70 },
-        {   0,  67 }, {   2,  57 }, {  -2,  76 }, {  11,  35 },
-        {   4,  64 }, {   1,  61 }, {  11,  35 }, {  18,  25 },
-        {  12,  24 }, {  13,  29 }, {  13,  36 }, { -10,  93 },
-        {  -7,  73 }, {  -2,  73 }, {  13,  46 }, {   9,  49 },
-        {  -7, 100 }, {   9,  53 }, {   2,  53 }, {   5,  53 },
-        {  -2,  61 }, {   0,  56 }, {   0,  56 }, { -13,  63 },
-        {  -5,  60 }, {  -1,  62 }, {   4,  57 }, {  -6,  69 },
-        {   4,  57 }, {  14,  39 }, {   4,  51 }, {  13,  68 },
-        {   3,  64 }, {   1,  61 }, {   9,  63 }, {   7,  50 },
-        {  16,  39 }, {   5,  44 }, {   4,  52 }, {  11,  48 },
-        {  -5,  60 }, {  -1,  59 }, {   0,  59 }, {  22,  33 },
-        {   5,  44 }, {  14,  43 }, {  -1,  78 }, {   0,  60 },
-        {   9,  69 },
-
-        /* 166 - 226 */
-        {  11,  28 }, {   2,  40 }, {   3,  44 }, {   0,  49 },
-        {   0,  46 }, {   2,  44 }, {   2,  51 }, {   0,  47 },
-        {   4,  39 }, {   2,  62 }, {   6,  46 }, {   0,  54 },
-        {   3,  54 }, {   2,  58 }, {   4,  63 }, {   6,  51 },
-        {   6,  57 }, {   7,  53 }, {   6,  52 }, {   6,  55 },
-        {  11,  45 }, {  14,  36 }, {   8,  53 }, {  -1,  82 },
-        {   7,  55 }, {  -3,  78 }, {  15,  46 }, {  22,  31 },
-        {  -1,  84 }, {  25,   7 }, {  30,  -7 }, {  28,   3 },
-        {  28,   4 }, {  32,   0 }, {  34,  -1 }, {  30,   6 },
-        {  30,   6 }, {  32,   9 }, {  31,  19 }, {  26,  27 },
-        {  26,  30 }, {  37,  20 }, {  28,  34 }, {  17,  70 },
-        {   1,  67 }, {   5,  59 }, {   9,  67 }, {  16,  30 },
-        {  18,  32 }, {  18,  35 }, {  22,  29 }, {  24,  31 },
-        {  23,  38 }, {  18,  43 }, {  20,  41 }, {  11,  63 },
-        {   9,  59 }, {   9,  64 }, {  -1,  94 }, {  -2,  89 },
-        {  -9, 108 },
-
-        /* 227 - 275 */
-        {  -6,  76 }, {  -2,  44 }, {   0,  45 }, {   0,  52 },
-        {  -3,  64 }, {  -2,  59 }, {  -4,  70 }, {  -4,  75 },
-        {  -8,  82 }, { -17, 102 }, {  -9,  77 }, {   3,  24 },
-        {   0,  42 }, {   0,  48 }, {   0,  55 }, {  -6,  59 },
-        {  -7,  71 }, { -12,  83 }, { -11,  87 }, { -30, 119 },
-        {   1,  58 }, {  -3,  29 }, {  -1,  36 }, {   1,  38 },
-        {   2,  43 }, {  -6,  55 }, {   0,  58 }, {   0,  64 },
-        {  -3,  74 }, { -10,  90 }, {   0,  70 }, {  -4,  29 },
-        {   5,  31 }, {   7,  42 }, {   1,  59 }, {  -2,  58 },
-        {  -3,  72 }, {  -3,  81 }, { -11,  97 }, {   0,  58 },
-        {   8,   5 }, {  10,  14 }, {  14,  18 }, {  13,  27 },
-        {   2,  40 }, {   0,  58 }, {  -3,  70 }, {  -6,  79 },
-        {  -8,  85 },
-
-        /* 276 a bit special (not used, x264_cabac_encode_bypass is used instead) */
-        { 0, 0 },
-
-        /* 277 - 337 */
-        { -13, 106 }, { -16, 106 }, { -10,  87 }, { -21, 114 },
-        { -18, 110 }, { -14,  98 }, { -22, 110 }, { -21, 106 },
-        { -18, 103 }, { -21, 107 }, { -23, 108 }, { -26, 112 },
-        { -10,  96 }, { -12,  95 }, {  -5,  91 }, {  -9,  93 },
-        { -22,  94 }, {  -5,  86 }, {   9,  67 }, {  -4,  80 },
-        { -10,  85 }, {  -1,  70 }, {   7,  60 }, {   9,  58 },
-        {   5,  61 }, {  12,  50 }, {  15,  50 }, {  18,  49 },
-        {  17,  54 }, {  10,  41 }, {   7,  46 }, {  -1,  51 },
-        {   7,  49 }, {   8,  52 }, {   9,  41 }, {   6,  47 },
-        {   2,  55 }, {  13,  41 }, {  10,  44 }, {   6,  50 },
-        {   5,  53 }, {  13,  49 }, {   4,  63 }, {   6,  64 },
-        {  -2,  69 }, {  -2,  59 }, {   6,  70 }, {  10,  44 },
-        {   9,  31 }, {  12,  43 }, {   3,  53 }, {  14,  34 },
-        {  10,  38 }, {  -3,  52 }, {  13,  40 }, {  17,  32 },
-        {   7,  44 }, {   7,  38 }, {  13,  50 }, {  10,  57 },
-        {  26,  43 },
-
-        /* 338 - 398 */
-        {  14,  11 }, {  11,  14 }, {   9,  11 }, {  18,  11 },
-        {  21,   9 }, {  23,  -2 }, {  32, -15 }, {  32, -15 },
-        {  34, -21 }, {  39, -23 }, {  42, -33 }, {  41, -31 },
-        {  46, -28 }, {  38, -12 }, {  21,  29 }, {  45, -24 },
-        {  53, -45 }, {  48, -26 }, {  65, -43 }, {  43, -19 },
-        {  39, -10 }, {  30,   9 }, {  18,  26 }, {  20,  27 },
-        {   0,  57 }, { -14,  82 }, {  -5,  75 }, { -19,  97 },
-        { -35, 125 }, {  27,   0 }, {  28,   0 }, {  31,  -4 },
-        {  27,   6 }, {  34,   8 }, {  30,  10 }, {  24,  22 },
-        {  33,  19 }, {  22,  32 }, {  26,  31 }, {  21,  41 },
-        {  26,  44 }, {  23,  47 }, {  16,  65 }, {  14,  71 },
-        {   8,  60 }, {   6,  63 }, {  17,  65 }, {  21,  24 },
-        {  23,  20 }, {  26,  23 }, {  27,  32 }, {  28,  23 },
-        {  28,  24 }, {  23,  40 }, {  24,  32 }, {  28,  29 },
-        {  23,  42 }, {  19,  57 }, {  22,  53 }, {  22,  61 },
-        {  11,  86 },
-
-        /* 399 -> 435 */
-        {  12,  40 }, {  11,  51 }, {  14,  59 },
-        {  -4,  79 }, {  -7,  71 }, {  -5,  69 }, {  -9,  70 },
-        {  -8,  66 }, { -10,  68 }, { -19,  73 }, { -12,  69 },
-        { -16,  70 }, { -15,  67 }, { -20,  62 }, { -19,  70 },
-        { -16,  66 }, { -22,  65 }, { -20,  63 }, {   9,  -2 },
-        {  26,  -9 }, {  33,  -9 }, {  39,  -7 }, {  41,  -2 },
-        {  45,   3 }, {  49,   9 }, {  45,  27 }, {  36,  59 },
-        {  -6,  66 }, {  -7,  35 }, {  -7,  42 }, {  -8,  45 },
-        {  -5,  48 }, { -12,  56 }, {  -6,  60 }, {  -5,  62 },
-        {  -8,  66 }, {  -8,  76 },
-
-        /* 436 -> 459 */
-        {  -5,  85 }, {  -6,  81 }, { -10,  77 }, {  -7,  81 },
-        { -17,  80 }, { -18,  73 }, {  -4,  74 }, { -10,  83 },
-        {  -9,  71 }, {  -9,  67 }, {  -1,  61 }, {  -8,  66 },
-        { -14,  66 }, {   0,  59 }, {   2,  59 }, {  21, -13 },
-        {  33, -14 }, {  39,  -7 }, {  46,  -2 }, {  51,   2 },
-        {  60,   6 }, {  61,  17 }, {  55,  34 }, {  42,  62 },
-
-        /* 460 - 1024 */
-        {  -7,  92 }, {  -5,  89 }, {  -7,  96 }, { -13, 108 },
-        {  -3,  46 }, {  -1,  65 }, {  -1,  57 }, {  -9,  93 },
-        {  -3,  74 }, {  -9,  92 }, {  -8,  87 }, { -23, 126 },
-        {  -7,  92 }, {  -5,  89 }, {  -7,  96 }, { -13, 108 },
-        {  -3,  46 }, {  -1,  65 }, {  -1,  57 }, {  -9,  93 },
-        {  -3,  74 }, {  -9,  92 }, {  -8,  87 }, { -23, 126 },
-        {  -2,  85 }, {  -6,  78 }, {  -1,  75 }, {  -7,  77 },
-        {   2,  54 }, {   5,  50 }, {  -3,  68 }, {   1,  50 },
-        {   6,  42 }, {  -4,  81 }, {   1,  63 }, {  -4,  70 },
-        {   0,  67 }, {   2,  57 }, {  -2,  76 }, {  11,  35 },
-        {   4,  64 }, {   1,  61 }, {  11,  35 }, {  18,  25 },
-        {  12,  24 }, {  13,  29 }, {  13,  36 }, { -10,  93 },
-        {  -7,  73 }, {  -2,  73 }, {  13,  46 }, {   9,  49 },
-        {  -7, 100 }, {   9,  53 }, {   2,  53 }, {   5,  53 },
-        {  -2,  61 }, {   0,  56 }, {   0,  56 }, { -13,  63 },
-        {  -5,  60 }, {  -1,  62 }, {   4,  57 }, {  -6,  69 },
-        {   4,  57 }, {  14,  39 }, {   4,  51 }, {  13,  68 },
-        {  -2,  85 }, {  -6,  78 }, {  -1,  75 }, {  -7,  77 },
-        {   2,  54 }, {   5,  50 }, {  -3,  68 }, {   1,  50 },
-        {   6,  42 }, {  -4,  81 }, {   1,  63 }, {  -4,  70 },
-        {   0,  67 }, {   2,  57 }, {  -2,  76 }, {  11,  35 },
-        {   4,  64 }, {   1,  61 }, {  11,  35 }, {  18,  25 },
-        {  12,  24 }, {  13,  29 }, {  13,  36 }, { -10,  93 },
-        {  -7,  73 }, {  -2,  73 }, {  13,  46 }, {   9,  49 },
-        {  -7, 100 }, {   9,  53 }, {   2,  53 }, {   5,  53 },
-        {  -2,  61 }, {   0,  56 }, {   0,  56 }, { -13,  63 },
-        {  -5,  60 }, {  -1,  62 }, {   4,  57 }, {  -6,  69 },
-        {   4,  57 }, {  14,  39 }, {   4,  51 }, {  13,  68 },
-        {  11,  28 }, {   2,  40 }, {   3,  44 }, {   0,  49 },
-        {   0,  46 }, {   2,  44 }, {   2,  51 }, {   0,  47 },
-        {   4,  39 }, {   2,  62 }, {   6,  46 }, {   0,  54 },
-        {   3,  54 }, {   2,  58 }, {   4,  63 }, {   6,  51 },
-        {   6,  57 }, {   7,  53 }, {   6,  52 }, {   6,  55 },
-        {  11,  45 }, {  14,  36 }, {   8,  53 }, {  -1,  82 },
-        {   7,  55 }, {  -3,  78 }, {  15,  46 }, {  22,  31 },
-        {  -1,  84 }, {  25,   7 }, {  30,  -7 }, {  28,   3 },
-        {  28,   4 }, {  32,   0 }, {  34,  -1 }, {  30,   6 },
-        {  30,   6 }, {  32,   9 }, {  31,  19 }, {  26,  27 },
-        {  26,  30 }, {  37,  20 }, {  28,  34 }, {  17,  70 },
-        {  11,  28 }, {   2,  40 }, {   3,  44 }, {   0,  49 },
-        {   0,  46 }, {   2,  44 }, {   2,  51 }, {   0,  47 },
-        {   4,  39 }, {   2,  62 }, {   6,  46 }, {   0,  54 },
-        {   3,  54 }, {   2,  58 }, {   4,  63 }, {   6,  51 },
-        {   6,  57 }, {   7,  53 }, {   6,  52 }, {   6,  55 },
-        {  11,  45 }, {  14,  36 }, {   8,  53 }, {  -1,  82 },
-        {   7,  55 }, {  -3,  78 }, {  15,  46 }, {  22,  31 },
-        {  -1,  84 }, {  25,   7 }, {  30,  -7 }, {  28,   3 },
-        {  28,   4 }, {  32,   0 }, {  34,  -1 }, {  30,   6 },
-        {  30,   6 }, {  32,   9 }, {  31,  19 }, {  26,  27 },
-        {  26,  30 }, {  37,  20 }, {  28,  34 }, {  17,  70 },
-        {  -4,  79 }, {  -7,  71 }, {  -5,  69 }, {  -9,  70 },
-        {  -8,  66 }, { -10,  68 }, { -19,  73 }, { -12,  69 },
-        { -16,  70 }, { -15,  67 }, { -20,  62 }, { -19,  70 },
-        { -16,  66 }, { -22,  65 }, { -20,  63 }, {  -5,  85 },
-        {  -6,  81 }, { -10,  77 }, {  -7,  81 }, { -17,  80 },
-        { -18,  73 }, {  -4,  74 }, { -10,  83 }, {  -9,  71 },
-        {  -9,  67 }, {  -1,  61 }, {  -8,  66 }, { -14,  66 },
-        {   0,  59 }, {   2,  59 }, {   9,  -2 }, {  26,  -9 },
-        {  33,  -9 }, {  39,  -7 }, {  41,  -2 }, {  45,   3 },
-        {  49,   9 }, {  45,  27 }, {  36,  59 }, {  21, -13 },
-        {  33, -14 }, {  39,  -7 }, {  46,  -2 }, {  51,   2 },
-        {  60,   6 }, {  61,  17 }, {  55,  34 }, {  42,  62 },
-        {  -6,  66 }, {  -7,  35 }, {  -7,  42 }, {  -8,  45 },
-        {  -5,  48 }, { -12,  56 }, {  -6,  60 }, {  -5,  62 },
-        {  -8,  66 }, {  -8,  76 }, {  -4,  79 }, {  -7,  71 },
-        {  -5,  69 }, {  -9,  70 }, {  -8,  66 }, { -10,  68 },
-        { -19,  73 }, { -12,  69 }, { -16,  70 }, { -15,  67 },
-        { -20,  62 }, { -19,  70 }, { -16,  66 }, { -22,  65 },
-        { -20,  63 }, {  -5,  85 }, {  -6,  81 }, { -10,  77 },
-        {  -7,  81 }, { -17,  80 }, { -18,  73 }, {  -4,  74 },
-        { -10,  83 }, {  -9,  71 }, {  -9,  67 }, {  -1,  61 },
-        {  -8,  66 }, { -14,  66 }, {   0,  59 }, {   2,  59 },
-        {   9,  -2 }, {  26,  -9 }, {  33,  -9 }, {  39,  -7 },
-        {  41,  -2 }, {  45,   3 }, {  49,   9 }, {  45,  27 },
-        {  36,  59 }, {  21, -13 }, {  33, -14 }, {  39,  -7 },
-        {  46,  -2 }, {  51,   2 }, {  60,   6 }, {  61,  17 },
-        {  55,  34 }, {  42,  62 }, {  -6,  66 }, {  -7,  35 },
-        {  -7,  42 }, {  -8,  45 }, {  -5,  48 }, { -12,  56 },
-        {  -6,  60 }, {  -5,  62 }, {  -8,  66 }, {  -8,  76 },
-        { -13, 106 }, { -16, 106 }, { -10,  87 }, { -21, 114 },
-        { -18, 110 }, { -14,  98 }, { -22, 110 }, { -21, 106 },
-        { -18, 103 }, { -21, 107 }, { -23, 108 }, { -26, 112 },
-        { -10,  96 }, { -12,  95 }, {  -5,  91 }, {  -9,  93 },
-        { -22,  94 }, {  -5,  86 }, {   9,  67 }, {  -4,  80 },
-        { -10,  85 }, {  -1,  70 }, {   7,  60 }, {   9,  58 },
-        {   5,  61 }, {  12,  50 }, {  15,  50 }, {  18,  49 },
-        {  17,  54 }, {  10,  41 }, {   7,  46 }, {  -1,  51 },
-        {   7,  49 }, {   8,  52 }, {   9,  41 }, {   6,  47 },
-        {   2,  55 }, {  13,  41 }, {  10,  44 }, {   6,  50 },
-        {   5,  53 }, {  13,  49 }, {   4,  63 }, {   6,  64 },
-        { -13, 106 }, { -16, 106 }, { -10,  87 }, { -21, 114 },
-        { -18, 110 }, { -14,  98 }, { -22, 110 }, { -21, 106 },
-        { -18, 103 }, { -21, 107 }, { -23, 108 }, { -26, 112 },
-        { -10,  96 }, { -12,  95 }, {  -5,  91 }, {  -9,  93 },
-        { -22,  94 }, {  -5,  86 }, {   9,  67 }, {  -4,  80 },
-        { -10,  85 }, {  -1,  70 }, {   7,  60 }, {   9,  58 },
-        {   5,  61 }, {  12,  50 }, {  15,  50 }, {  18,  49 },
-        {  17,  54 }, {  10,  41 }, {   7,  46 }, {  -1,  51 },
-        {   7,  49 }, {   8,  52 }, {   9,  41 }, {   6,  47 },
-        {   2,  55 }, {  13,  41 }, {  10,  44 }, {   6,  50 },
-        {   5,  53 }, {  13,  49 }, {   4,  63 }, {   6,  64 },
-        {  14,  11 }, {  11,  14 }, {   9,  11 }, {  18,  11 },
-        {  21,   9 }, {  23,  -2 }, {  32, -15 }, {  32, -15 },
-        {  34, -21 }, {  39, -23 }, {  42, -33 }, {  41, -31 },
-        {  46, -28 }, {  38, -12 }, {  21,  29 }, {  45, -24 },
-        {  53, -45 }, {  48, -26 }, {  65, -43 }, {  43, -19 },
-        {  39, -10 }, {  30,   9 }, {  18,  26 }, {  20,  27 },
-        {   0,  57 }, { -14,  82 }, {  -5,  75 }, { -19,  97 },
-        { -35, 125 }, {  27,   0 }, {  28,   0 }, {  31,  -4 },
-        {  27,   6 }, {  34,   8 }, {  30,  10 }, {  24,  22 },
-        {  33,  19 }, {  22,  32 }, {  26,  31 }, {  21,  41 },
-        {  26,  44 }, {  23,  47 }, {  16,  65 }, {  14,  71 },
-        {  14,  11 }, {  11,  14 }, {   9,  11 }, {  18,  11 },
-        {  21,   9 }, {  23,  -2 }, {  32, -15 }, {  32, -15 },
-        {  34, -21 }, {  39, -23 }, {  42, -33 }, {  41, -31 },
-        {  46, -28 }, {  38, -12 }, {  21,  29 }, {  45, -24 },
-        {  53, -45 }, {  48, -26 }, {  65, -43 }, {  43, -19 },
-        {  39, -10 }, {  30,   9 }, {  18,  26 }, {  20,  27 },
-        {   0,  57 }, { -14,  82 }, {  -5,  75 }, { -19,  97 },
-        { -35, 125 }, {  27,   0 }, {  28,   0 }, {  31,  -4 },
-        {  27,   6 }, {  34,   8 }, {  30,  10 }, {  24,  22 },
-        {  33,  19 }, {  22,  32 }, {  26,  31 }, {  21,  41 },
-        {  26,  44 }, {  23,  47 }, {  16,  65 }, {  14,  71 },
-        {  -6,  76 }, {  -2,  44 }, {   0,  45 }, {   0,  52 },
-        {  -3,  64 }, {  -2,  59 }, {  -4,  70 }, {  -4,  75 },
-        {  -8,  82 }, { -17, 102 }, {  -9,  77 }, {   3,  24 },
-        {   0,  42 }, {   0,  48 }, {   0,  55 }, {  -6,  59 },
-        {  -7,  71 }, { -12,  83 }, { -11,  87 }, { -30, 119 },
-        {   1,  58 }, {  -3,  29 }, {  -1,  36 }, {   1,  38 },
-        {   2,  43 }, {  -6,  55 }, {   0,  58 }, {   0,  64 },
-        {  -3,  74 }, { -10,  90 }, {  -6,  76 }, {  -2,  44 },
-        {   0,  45 }, {   0,  52 }, {  -3,  64 }, {  -2,  59 },
-        {  -4,  70 }, {  -4,  75 }, {  -8,  82 }, { -17, 102 },
-        {  -9,  77 }, {   3,  24 }, {   0,  42 }, {   0,  48 },
-        {   0,  55 }, {  -6,  59 }, {  -7,  71 }, { -12,  83 },
-        { -11,  87 }, { -30, 119 }, {   1,  58 }, {  -3,  29 },
-        {  -1,  36 }, {   1,  38 }, {   2,  43 }, {  -6,  55 },
-        {   0,  58 }, {   0,  64 }, {  -3,  74 }, { -10,  90 },
-        {  -3,  74 }, {  -9,  92 }, {  -8,  87 }, { -23, 126 },
-        {  -3,  74 }, {  -9,  92 }, {  -8,  87 }, { -23, 126 },
-        {  -3,  74 }, {  -9,  92 }, {  -8,  87 }, { -23, 126 }
-    },
-
-    /* i_cabac_init_idc == 1 */
-    {
-        /* 0 - 10 */
-        {  20, -15 }, {   2,  54 }, {   3,  74 }, {  20, -15 },
-        {   2,  54 }, {   3,  74 }, { -28, 127 }, { -23, 104 },
-        {  -6,  53 }, {  -1,  54 }, {   7,  51 },
-
-        /* 11 - 23 */
-        {  22,  25 }, {  34,   0 }, {  16,   0 }, {  -2,   9 },
-        {   4,  41 }, { -29, 118 }, {   2,  65 }, {  -6,  71 },
-        { -13,  79 }, {   5,  52 }, {   9,  50 }, {  -3,  70 },
-        {  10,  54 },
-
-        /* 24 - 39 */
-        {  26,  34 }, {  19,  22 }, {  40,   0 }, {  57,   2 },
-        {  41,  36 }, {  26,  69 }, { -45, 127 }, { -15, 101 },
-        {  -4,  76 }, {  -6,  71 }, { -13,  79 }, {   5,  52 },
-        {   6,  69 }, { -13,  90 }, {   0,  52 }, {   8,  43 },
-
-        /* 40 - 53 */
-        {  -2,  69 },{  -5,  82 },{ -10,  96 },{   2,  59 },
-        {   2,  75 },{  -3,  87 },{  -3,  100 },{   1,  56 },
-        {  -3,  74 },{  -6,  85 },{   0,  59 },{  -3,  81 },
-        {  -7,  86 },{  -5,  95 },
-
-        /* 54 - 59 */
-        {  -1,  66 },{  -1,  77 },{   1,  70 },{  -2,  86 },
-        {  -5,  72 },{   0,  61 },
-
-        /* 60 - 69 */
-        { 0, 41 },   { 0, 63 },   { 0, 63 },     { 0, 63 },
-        { -9, 83 },  { 4, 86 },   { 0, 97 },     { -7, 72 },
-        { 13, 41 },  { 3, 62 },
-
-        /* 70 - 104 */
-        {  13,  15 }, {   7,  51 }, {   2,  80 }, { -39, 127 },
-        { -18,  91 }, { -17,  96 }, { -26,  81 }, { -35,  98 },
-        { -24, 102 }, { -23,  97 }, { -27, 119 }, { -24,  99 },
-        { -21, 110 }, { -18, 102 }, { -36, 127 }, {   0,  80 },
-        {  -5,  89 }, {  -7,  94 }, {  -4,  92 }, {   0,  39 },
-        {   0,  65 }, { -15,  84 }, { -35, 127 }, {  -2,  73 },
-        { -12, 104 }, {  -9,  91 }, { -31, 127 }, {   3,  55 },
-        {   7,  56 }, {   7,  55 }, {   8,  61 }, {  -3,  53 },
-        {   0,  68 }, {  -7,  74 }, {  -9,  88 },
-
-        /* 105 -> 165 */
-        { -13, 103 }, { -13,  91 }, {  -9,  89 }, { -14,  92 },
-        {  -8,  76 }, { -12,  87 }, { -23, 110 }, { -24, 105 },
-        { -10,  78 }, { -20, 112 }, { -17,  99 }, { -78, 127 },
-        { -70, 127 }, { -50, 127 }, { -46, 127 }, {  -4,  66 },
-        {  -5,  78 }, {  -4,  71 }, {  -8,  72 }, {   2,  59 },
-        {  -1,  55 }, {  -7,  70 }, {  -6,  75 }, {  -8,  89 },
-        { -34, 119 }, {  -3,  75 }, {  32,  20 }, {  30,  22 },
-        { -44, 127 }, {   0,  54 }, {  -5,  61 }, {   0,  58 },
-        {  -1,  60 }, {  -3,  61 }, {  -8,  67 }, { -25,  84 },
-        { -14,  74 }, {  -5,  65 }, {   5,  52 }, {   2,  57 },
-        {   0,  61 }, {  -9,  69 }, { -11,  70 }, {  18,  55 },
-        {  -4,  71 }, {   0,  58 }, {   7,  61 }, {   9,  41 },
-        {  18,  25 }, {   9,  32 }, {   5,  43 }, {   9,  47 },
-        {   0,  44 }, {   0,  51 }, {   2,  46 }, {  19,  38 },
-        {  -4,  66 }, {  15,  38 }, {  12,  42 }, {   9,  34 },
-        {   0,  89 },
-
-        /* 166 - 226 */
-        {   4,  45 }, {  10,  28 }, {  10,  31 }, {  33, -11 },
-        {  52, -43 }, {  18,  15 }, {  28,   0 }, {  35, -22 },
-        {  38, -25 }, {  34,   0 }, {  39, -18 }, {  32, -12 },
-        { 102, -94 }, {   0,   0 }, {  56, -15 }, {  33,  -4 },
-        {  29,  10 }, {  37,  -5 }, {  51, -29 }, {  39,  -9 },
-        {  52, -34 }, {  69, -58 }, {  67, -63 }, {  44,  -5 },
-        {  32,   7 }, {  55, -29 }, {  32,   1 }, {   0,   0 },
-        {  27,  36 }, {  33, -25 }, {  34, -30 }, {  36, -28 },
-        {  38, -28 }, {  38, -27 }, {  34, -18 }, {  35, -16 },
-        {  34, -14 }, {  32,  -8 }, {  37,  -6 }, {  35,   0 },
-        {  30,  10 }, {  28,  18 }, {  26,  25 }, {  29,  41 },
-        {   0,  75 }, {   2,  72 }, {   8,  77 }, {  14,  35 },
-        {  18,  31 }, {  17,  35 }, {  21,  30 }, {  17,  45 },
-        {  20,  42 }, {  18,  45 }, {  27,  26 }, {  16,  54 },
-        {   7,  66 }, {  16,  56 }, {  11,  73 }, {  10,  67 },
-        { -10, 116 },
-
-        /* 227 - 275 */
-        { -23, 112 }, { -15,  71 }, {  -7,  61 }, {   0,  53 },
-        {  -5,  66 }, { -11,  77 }, {  -9,  80 }, {  -9,  84 },
-        { -10,  87 }, { -34, 127 }, { -21, 101 }, {  -3,  39 },
-        {  -5,  53 }, {  -7,  61 }, { -11,  75 }, { -15,  77 },
-        { -17,  91 }, { -25, 107 }, { -25, 111 }, { -28, 122 },
-        { -11,  76 }, { -10,  44 }, { -10,  52 }, { -10,  57 },
-        {  -9,  58 }, { -16,  72 }, {  -7,  69 }, {  -4,  69 },
-        {  -5,  74 }, {  -9,  86 }, {   2,  66 }, {  -9,  34 },
-        {   1,  32 }, {  11,  31 }, {   5,  52 }, {  -2,  55 },
-        {  -2,  67 }, {   0,  73 }, {  -8,  89 }, {   3,  52 },
-        {   7,   4 }, {  10,   8 }, {  17,   8 }, {  16,  19 },
-        {   3,  37 }, {  -1,  61 }, {  -5,  73 }, {  -1,  70 },
-        {  -4,  78 },
-
-        /* 276 a bit special (not used, x264_cabac_encode_bypass is used instead) */
-        { 0, 0 },
-
-        /* 277 - 337 */
-        { -21, 126 }, { -23, 124 }, { -20, 110 }, { -26, 126 },
-        { -25, 124 }, { -17, 105 }, { -27, 121 }, { -27, 117 },
-        { -17, 102 }, { -26, 117 }, { -27, 116 }, { -33, 122 },
-        { -10,  95 }, { -14, 100 }, {  -8,  95 }, { -17, 111 },
-        { -28, 114 }, {  -6,  89 }, {  -2,  80 }, {  -4,  82 },
-        {  -9,  85 }, {  -8,  81 }, {  -1,  72 }, {   5,  64 },
-        {   1,  67 }, {   9,  56 }, {   0,  69 }, {   1,  69 },
-        {   7,  69 }, {  -7,  69 }, {  -6,  67 }, { -16,  77 },
-        {  -2,  64 }, {   2,  61 }, {  -6,  67 }, {  -3,  64 },
-        {   2,  57 }, {  -3,  65 }, {  -3,  66 }, {   0,  62 },
-        {   9,  51 }, {  -1,  66 }, {  -2,  71 }, {  -2,  75 },
-        {  -1,  70 }, {  -9,  72 }, {  14,  60 }, {  16,  37 },
-        {   0,  47 }, {  18,  35 }, {  11,  37 }, {  12,  41 },
-        {  10,  41 }, {   2,  48 }, {  12,  41 }, {  13,  41 },
-        {   0,  59 }, {   3,  50 }, {  19,  40 }, {   3,  66 },
-        {  18,  50 },
-
-        /* 338 - 398 */
-        {  19,  -6 }, {  18,  -6 }, {  14,   0 }, {  26, -12 },
-        {  31, -16 }, {  33, -25 }, {  33, -22 }, {  37, -28 },
-        {  39, -30 }, {  42, -30 }, {  47, -42 }, {  45, -36 },
-        {  49, -34 }, {  41, -17 }, {  32,   9 }, {  69, -71 },
-        {  63, -63 }, {  66, -64 }, {  77, -74 }, {  54, -39 },
-        {  52, -35 }, {  41, -10 }, {  36,   0 }, {  40,  -1 },
-        {  30,  14 }, {  28,  26 }, {  23,  37 }, {  12,  55 },
-        {  11,  65 }, {  37, -33 }, {  39, -36 }, {  40, -37 },
-        {  38, -30 }, {  46, -33 }, {  42, -30 }, {  40, -24 },
-        {  49, -29 }, {  38, -12 }, {  40, -10 }, {  38,  -3 },
-        {  46,  -5 }, {  31,  20 }, {  29,  30 }, {  25,  44 },
-        {  12,  48 }, {  11,  49 }, {  26,  45 }, {  22,  22 },
-        {  23,  22 }, {  27,  21 }, {  33,  20 }, {  26,  28 },
-        {  30,  24 }, {  27,  34 }, {  18,  42 }, {  25,  39 },
-        {  18,  50 }, {  12,  70 }, {  21,  54 }, {  14,  71 },
-        {  11,  83 },
-
-        /* 399 -> 435 */
-        {  25,  32 }, {  21,  49 }, {  21,  54 },
-        {  -5,  85 }, {  -6,  81 }, { -10,  77 }, {  -7,  81 },
-        { -17,  80 }, { -18,  73 }, {  -4,  74 }, { -10,  83 },
-        {  -9,  71 }, {  -9,  67 }, {  -1,  61 }, {  -8,  66 },
-        { -14,  66 }, {   0,  59 }, {   2,  59 }, {  17, -10 },
-        {  32, -13 }, {  42,  -9 }, {  49,  -5 }, {  53,   0 },
-        {  64,   3 }, {  68,  10 }, {  66,  27 }, {  47,  57 },
-        {  -5,  71 }, {   0,  24 }, {  -1,  36 }, {  -2,  42 },
-        {  -2,  52 }, {  -9,  57 }, {  -6,  63 }, {  -4,  65 },
-        {  -4,  67 }, {  -7,  82 },
-
-        /* 436 -> 459 */
-        {  -3,  81 }, {  -3,  76 }, {  -7,  72 }, {  -6,  78 },
-        { -12,  72 }, { -14,  68 }, {  -3,  70 }, {  -6,  76 },
-        {  -5,  66 }, {  -5,  62 }, {   0,  57 }, {  -4,  61 },
-        {  -9,  60 }, {   1,  54 }, {   2,  58 }, {  17, -10 },
-        {  32, -13 }, {  42,  -9 }, {  49,  -5 }, {  53,   0 },
-        {  64,   3 }, {  68,  10 }, {  66,  27 }, {  47,  57 },
-
-        /* 460 - 1024 */
-        {   0,  80 }, {  -5,  89 }, {  -7,  94 }, {  -4,  92 },
-        {   0,  39 }, {   0,  65 }, { -15,  84 }, { -35, 127 },
-        {  -2,  73 }, { -12, 104 }, {  -9,  91 }, { -31, 127 },
-        {   0,  80 }, {  -5,  89 }, {  -7,  94 }, {  -4,  92 },
-        {   0,  39 }, {   0,  65 }, { -15,  84 }, { -35, 127 },
-        {  -2,  73 }, { -12, 104 }, {  -9,  91 }, { -31, 127 },
-        { -13, 103 }, { -13,  91 }, {  -9,  89 }, { -14,  92 },
-        {  -8,  76 }, { -12,  87 }, { -23, 110 }, { -24, 105 },
-        { -10,  78 }, { -20, 112 }, { -17,  99 }, { -78, 127 },
-        { -70, 127 }, { -50, 127 }, { -46, 127 }, {  -4,  66 },
-        {  -5,  78 }, {  -4,  71 }, {  -8,  72 }, {   2,  59 },
-        {  -1,  55 }, {  -7,  70 }, {  -6,  75 }, {  -8,  89 },
-        { -34, 119 }, {  -3,  75 }, {  32,  20 }, {  30,  22 },
-        { -44, 127 }, {   0,  54 }, {  -5,  61 }, {   0,  58 },
-        {  -1,  60 }, {  -3,  61 }, {  -8,  67 }, { -25,  84 },
-        { -14,  74 }, {  -5,  65 }, {   5,  52 }, {   2,  57 },
-        {   0,  61 }, {  -9,  69 }, { -11,  70 }, {  18,  55 },
-        { -13, 103 }, { -13,  91 }, {  -9,  89 }, { -14,  92 },
-        {  -8,  76 }, { -12,  87 }, { -23, 110 }, { -24, 105 },
-        { -10,  78 }, { -20, 112 }, { -17,  99 }, { -78, 127 },
-        { -70, 127 }, { -50, 127 }, { -46, 127 }, {  -4,  66 },
-        {  -5,  78 }, {  -4,  71 }, {  -8,  72 }, {   2,  59 },
-        {  -1,  55 }, {  -7,  70 }, {  -6,  75 }, {  -8,  89 },
-        { -34, 119 }, {  -3,  75 }, {  32,  20 }, {  30,  22 },
-        { -44, 127 }, {   0,  54 }, {  -5,  61 }, {   0,  58 },
-        {  -1,  60 }, {  -3,  61 }, {  -8,  67 }, { -25,  84 },
-        { -14,  74 }, {  -5,  65 }, {   5,  52 }, {   2,  57 },
-        {   0,  61 }, {  -9,  69 }, { -11,  70 }, {  18,  55 },
-        {   4,  45 }, {  10,  28 }, {  10,  31 }, {  33, -11 },
-        {  52, -43 }, {  18,  15 }, {  28,   0 }, {  35, -22 },
-        {  38, -25 }, {  34,   0 }, {  39, -18 }, {  32, -12 },
-        { 102, -94 }, {   0,   0 }, {  56, -15 }, {  33,  -4 },
-        {  29,  10 }, {  37,  -5 }, {  51, -29 }, {  39,  -9 },
-        {  52, -34 }, {  69, -58 }, {  67, -63 }, {  44,  -5 },
-        {  32,   7 }, {  55, -29 }, {  32,   1 }, {   0,   0 },
-        {  27,  36 }, {  33, -25 }, {  34, -30 }, {  36, -28 },
-        {  38, -28 }, {  38, -27 }, {  34, -18 }, {  35, -16 },
-        {  34, -14 }, {  32,  -8 }, {  37,  -6 }, {  35,   0 },
-        {  30,  10 }, {  28,  18 }, {  26,  25 }, {  29,  41 },
-        {   4,  45 }, {  10,  28 }, {  10,  31 }, {  33, -11 },
-        {  52, -43 }, {  18,  15 }, {  28,   0 }, {  35, -22 },
-        {  38, -25 }, {  34,   0 }, {  39, -18 }, {  32, -12 },
-        { 102, -94 }, {   0,   0 }, {  56, -15 }, {  33,  -4 },
-        {  29,  10 }, {  37,  -5 }, {  51, -29 }, {  39,  -9 },
-        {  52, -34 }, {  69, -58 }, {  67, -63 }, {  44,  -5 },
-        {  32,   7 }, {  55, -29 }, {  32,   1 }, {   0,   0 },
-        {  27,  36 }, {  33, -25 }, {  34, -30 }, {  36, -28 },
-        {  38, -28 }, {  38, -27 }, {  34, -18 }, {  35, -16 },
-        {  34, -14 }, {  32,  -8 }, {  37,  -6 }, {  35,   0 },
-        {  30,  10 }, {  28,  18 }, {  26,  25 }, {  29,  41 },
-        {  -5,  85 }, {  -6,  81 }, { -10,  77 }, {  -7,  81 },
-        { -17,  80 }, { -18,  73 }, {  -4,  74 }, { -10,  83 },
-        {  -9,  71 }, {  -9,  67 }, {  -1,  61 }, {  -8,  66 },
-        { -14,  66 }, {   0,  59 }, {   2,  59 }, {  -3,  81 },
-        {  -3,  76 }, {  -7,  72 }, {  -6,  78 }, { -12,  72 },
-        { -14,  68 }, {  -3,  70 }, {  -6,  76 }, {  -5,  66 },
-        {  -5,  62 }, {   0,  57 }, {  -4,  61 }, {  -9,  60 },
-        {   1,  54 }, {   2,  58 }, {  17, -10 }, {  32, -13 },
-        {  42,  -9 }, {  49,  -5 }, {  53,   0 }, {  64,   3 },
-        {  68,  10 }, {  66,  27 }, {  47,  57 }, {  17, -10 },
-        {  32, -13 }, {  42,  -9 }, {  49,  -5 }, {  53,   0 },
-        {  64,   3 }, {  68,  10 }, {  66,  27 }, {  47,  57 },
-        {  -5,  71 }, {   0,  24 }, {  -1,  36 }, {  -2,  42 },
-        {  -2,  52 }, {  -9,  57 }, {  -6,  63 }, {  -4,  65 },
-        {  -4,  67 }, {  -7,  82 }, {  -5,  85 }, {  -6,  81 },
-        { -10,  77 }, {  -7,  81 }, { -17,  80 }, { -18,  73 },
-        {  -4,  74 }, { -10,  83 }, {  -9,  71 }, {  -9,  67 },
-        {  -1,  61 }, {  -8,  66 }, { -14,  66 }, {   0,  59 },
-        {   2,  59 }, {  -3,  81 }, {  -3,  76 }, {  -7,  72 },
-        {  -6,  78 }, { -12,  72 }, { -14,  68 }, {  -3,  70 },
-        {  -6,  76 }, {  -5,  66 }, {  -5,  62 }, {   0,  57 },
-        {  -4,  61 }, {  -9,  60 }, {   1,  54 }, {   2,  58 },
-        {  17, -10 }, {  32, -13 }, {  42,  -9 }, {  49,  -5 },
-        {  53,   0 }, {  64,   3 }, {  68,  10 }, {  66,  27 },
-        {  47,  57 }, {  17, -10 }, {  32, -13 }, {  42,  -9 },
-        {  49,  -5 }, {  53,   0 }, {  64,   3 }, {  68,  10 },
-        {  66,  27 }, {  47,  57 }, {  -5,  71 }, {   0,  24 },
-        {  -1,  36 }, {  -2,  42 }, {  -2,  52 }, {  -9,  57 },
-        {  -6,  63 }, {  -4,  65 }, {  -4,  67 }, {  -7,  82 },
-        { -21, 126 }, { -23, 124 }, { -20, 110 }, { -26, 126 },
-        { -25, 124 }, { -17, 105 }, { -27, 121 }, { -27, 117 },
-        { -17, 102 }, { -26, 117 }, { -27, 116 }, { -33, 122 },
-        { -10,  95 }, { -14, 100 }, {  -8,  95 }, { -17, 111 },
-        { -28, 114 }, {  -6,  89 }, {  -2,  80 }, {  -4,  82 },
-        {  -9,  85 }, {  -8,  81 }, {  -1,  72 }, {   5,  64 },
-        {   1,  67 }, {   9,  56 }, {   0,  69 }, {   1,  69 },
-        {   7,  69 }, {  -7,  69 }, {  -6,  67 }, { -16,  77 },
-        {  -2,  64 }, {   2,  61 }, {  -6,  67 }, {  -3,  64 },
-        {   2,  57 }, {  -3,  65 }, {  -3,  66 }, {   0,  62 },
-        {   9,  51 }, {  -1,  66 }, {  -2,  71 }, {  -2,  75 },
-        { -21, 126 }, { -23, 124 }, { -20, 110 }, { -26, 126 },
-        { -25, 124 }, { -17, 105 }, { -27, 121 }, { -27, 117 },
-        { -17, 102 }, { -26, 117 }, { -27, 116 }, { -33, 122 },
-        { -10,  95 }, { -14, 100 }, {  -8,  95 }, { -17, 111 },
-        { -28, 114 }, {  -6,  89 }, {  -2,  80 }, {  -4,  82 },
-        {  -9,  85 }, {  -8,  81 }, {  -1,  72 }, {   5,  64 },
-        {   1,  67 }, {   9,  56 }, {   0,  69 }, {   1,  69 },
-        {   7,  69 }, {  -7,  69 }, {  -6,  67 }, { -16,  77 },
-        {  -2,  64 }, {   2,  61 }, {  -6,  67 }, {  -3,  64 },
-        {   2,  57 }, {  -3,  65 }, {  -3,  66 }, {   0,  62 },
-        {   9,  51 }, {  -1,  66 }, {  -2,  71 }, {  -2,  75 },
-        {  19,  -6 }, {  18,  -6 }, {  14,   0 }, {  26, -12 },
-        {  31, -16 }, {  33, -25 }, {  33, -22 }, {  37, -28 },
-        {  39, -30 }, {  42, -30 }, {  47, -42 }, {  45, -36 },
-        {  49, -34 }, {  41, -17 }, {  32,   9 }, {  69, -71 },
-        {  63, -63 }, {  66, -64 }, {  77, -74 }, {  54, -39 },
-        {  52, -35 }, {  41, -10 }, {  36,   0 }, {  40,  -1 },
-        {  30,  14 }, {  28,  26 }, {  23,  37 }, {  12,  55 },
-        {  11,  65 }, {  37, -33 }, {  39, -36 }, {  40, -37 },
-        {  38, -30 }, {  46, -33 }, {  42, -30 }, {  40, -24 },
-        {  49, -29 }, {  38, -12 }, {  40, -10 }, {  38,  -3 },
-        {  46,  -5 }, {  31,  20 }, {  29,  30 }, {  25,  44 },
-        {  19,  -6 }, {  18,  -6 }, {  14,   0 }, {  26, -12 },
-        {  31, -16 }, {  33, -25 }, {  33, -22 }, {  37, -28 },
-        {  39, -30 }, {  42, -30 }, {  47, -42 }, {  45, -36 },
-        {  49, -34 }, {  41, -17 }, {  32,   9 }, {  69, -71 },
-        {  63, -63 }, {  66, -64 }, {  77, -74 }, {  54, -39 },
-        {  52, -35 }, {  41, -10 }, {  36,   0 }, {  40,  -1 },
-        {  30,  14 }, {  28,  26 }, {  23,  37 }, {  12,  55 },
-        {  11,  65 }, {  37, -33 }, {  39, -36 }, {  40, -37 },
-        {  38, -30 }, {  46, -33 }, {  42, -30 }, {  40, -24 },
-        {  49, -29 }, {  38, -12 }, {  40, -10 }, {  38,  -3 },
-        {  46,  -5 }, {  31,  20 }, {  29,  30 }, {  25,  44 },
-        { -23, 112 }, { -15,  71 }, {  -7,  61 }, {   0,  53 },
-        {  -5,  66 }, { -11,  77 }, {  -9,  80 }, {  -9,  84 },
-        { -10,  87 }, { -34, 127 }, { -21, 101 }, {  -3,  39 },
-        {  -5,  53 }, {  -7,  61 }, { -11,  75 }, { -15,  77 },
-        { -17,  91 }, { -25, 107 }, { -25, 111 }, { -28, 122 },
-        { -11,  76 }, { -10,  44 }, { -10,  52 }, { -10,  57 },
-        {  -9,  58 }, { -16,  72 }, {  -7,  69 }, {  -4,  69 },
-        {  -5,  74 }, {  -9,  86 }, { -23, 112 }, { -15,  71 },
-        {  -7,  61 }, {   0,  53 }, {  -5,  66 }, { -11,  77 },
-        {  -9,  80 }, {  -9,  84 }, { -10,  87 }, { -34, 127 },
-        { -21, 101 }, {  -3,  39 }, {  -5,  53 }, {  -7,  61 },
-        { -11,  75 }, { -15,  77 }, { -17,  91 }, { -25, 107 },
-        { -25, 111 }, { -28, 122 }, { -11,  76 }, { -10,  44 },
-        { -10,  52 }, { -10,  57 }, {  -9,  58 }, { -16,  72 },
-        {  -7,  69 }, {  -4,  69 }, {  -5,  74 }, {  -9,  86 },
-        {  -2,  73 }, { -12, 104 }, {  -9,  91 }, { -31, 127 },
-        {  -2,  73 }, { -12, 104 }, {  -9,  91 }, { -31, 127 },
-        {  -2,  73 }, { -12, 104 }, {  -9,  91 }, { -31, 127 }
-    },
-
-    /* i_cabac_init_idc == 2 */
-    {
-        /* 0 - 10 */
-        {  20, -15 }, {   2,  54 }, {   3,  74 }, {  20, -15 },
-        {   2,  54 }, {   3,  74 }, { -28, 127 }, { -23, 104 },
-        {  -6,  53 }, {  -1,  54 }, {   7,  51 },
-
-        /* 11 - 23 */
-        {  29,  16 }, {  25,   0 }, {  14,   0 }, { -10,  51 },
-        {  -3,  62 }, { -27,  99 }, {  26,  16 }, {  -4,  85 },
-        { -24, 102 }, {   5,  57 }, {   6,  57 }, { -17,  73 },
-        {  14,  57 },
-
-        /* 24 - 39 */
-        {  20,  40 }, {  20,  10 }, {  29,   0 }, {  54,   0 },
-        {  37,  42 }, {  12,  97 }, { -32, 127 }, { -22, 117 },
-        {  -2,  74 }, {  -4,  85 }, { -24, 102 }, {   5,  57 },
-        {  -6,  93 }, { -14,  88 }, {  -6,  44 }, {   4,  55 },
-
-        /* 40 - 53 */
-        { -11,  89 },{ -15,  103 },{ -21,  116 },{  19,  57 },
-        {  20,  58 },{   4,  84 },{   6,  96 },{   1,  63 },
-        {  -5,  85 },{ -13,  106 },{   5,  63 },{   6,  75 },
-        {  -3,  90 },{  -1,  101 },
-
-        /* 54 - 59 */
-        {   3,  55 },{  -4,  79 },{  -2,  75 },{ -12,  97 },
-        {  -7,  50 },{   1,  60 },
-
-        /* 60 - 69 */
-        { 0, 41 },   { 0, 63 },   { 0, 63 },     { 0, 63 },
-        { -9, 83 },  { 4, 86 },   { 0, 97 },     { -7, 72 },
-        { 13, 41 },  { 3, 62 },
-
-        /* 70 - 104 */
-        {   7,  34 }, {  -9,  88 }, { -20, 127 }, { -36, 127 },
-        { -17,  91 }, { -14,  95 }, { -25,  84 }, { -25,  86 },
-        { -12,  89 }, { -17,  91 }, { -31, 127 }, { -14,  76 },
-        { -18, 103 }, { -13,  90 }, { -37, 127 }, {  11,  80 },
-        {   5,  76 }, {   2,  84 }, {   5,  78 }, {  -6,  55 },
-        {   4,  61 }, { -14,  83 }, { -37, 127 }, {  -5,  79 },
-        { -11, 104 }, { -11,  91 }, { -30, 127 }, {   0,  65 },
-        {  -2,  79 }, {   0,  72 }, {  -4,  92 }, {  -6,  56 },
-        {   3,  68 }, {  -8,  71 }, { -13,  98 },
-
-        /* 105 -> 165 */
-        {  -4,  86 }, { -12,  88 }, {  -5,  82 }, {  -3,  72 },
-        {  -4,  67 }, {  -8,  72 }, { -16,  89 }, {  -9,  69 },
-        {  -1,  59 }, {   5,  66 }, {   4,  57 }, {  -4,  71 },
-        {  -2,  71 }, {   2,  58 }, {  -1,  74 }, {  -4,  44 },
-        {  -1,  69 }, {   0,  62 }, {  -7,  51 }, {  -4,  47 },
-        {  -6,  42 }, {  -3,  41 }, {  -6,  53 }, {   8,  76 },
-        {  -9,  78 }, { -11,  83 }, {   9,  52 }, {   0,  67 },
-        {  -5,  90 }, {   1,  67 }, { -15,  72 }, {  -5,  75 },
-        {  -8,  80 }, { -21,  83 }, { -21,  64 }, { -13,  31 },
-        { -25,  64 }, { -29,  94 }, {   9,  75 }, {  17,  63 },
-        {  -8,  74 }, {  -5,  35 }, {  -2,  27 }, {  13,  91 },
-        {   3,  65 }, {  -7,  69 }, {   8,  77 }, { -10,  66 },
-        {   3,  62 }, {  -3,  68 }, { -20,  81 }, {   0,  30 },
-        {   1,   7 }, {  -3,  23 }, { -21,  74 }, {  16,  66 },
-        { -23, 124 }, {  17,  37 }, {  44, -18 }, {  50, -34 },
-        { -22, 127 },
-
-        /* 166 - 226 */
-        {   4,  39 }, {   0,  42 }, {   7,  34 }, {  11,  29 },
-        {   8,  31 }, {   6,  37 }, {   7,  42 }, {   3,  40 },
-        {   8,  33 }, {  13,  43 }, {  13,  36 }, {   4,  47 },
-        {   3,  55 }, {   2,  58 }, {   6,  60 }, {   8,  44 },
-        {  11,  44 }, {  14,  42 }, {   7,  48 }, {   4,  56 },
-        {   4,  52 }, {  13,  37 }, {   9,  49 }, {  19,  58 },
-        {  10,  48 }, {  12,  45 }, {   0,  69 }, {  20,  33 },
-        {   8,  63 }, {  35, -18 }, {  33, -25 }, {  28,  -3 },
-        {  24,  10 }, {  27,   0 }, {  34, -14 }, {  52, -44 },
-        {  39, -24 }, {  19,  17 }, {  31,  25 }, {  36,  29 },
-        {  24,  33 }, {  34,  15 }, {  30,  20 }, {  22,  73 },
-        {  20,  34 }, {  19,  31 }, {  27,  44 }, {  19,  16 },
-        {  15,  36 }, {  15,  36 }, {  21,  28 }, {  25,  21 },
-        {  30,  20 }, {  31,  12 }, {  27,  16 }, {  24,  42 },
-        {   0,  93 }, {  14,  56 }, {  15,  57 }, {  26,  38 },
-        { -24, 127 },
-
-        /* 227 - 275 */
-        { -24, 115 }, { -22,  82 }, {  -9,  62 }, {   0,  53 },
-        {   0,  59 }, { -14,  85 }, { -13,  89 }, { -13,  94 },
-        { -11,  92 }, { -29, 127 }, { -21, 100 }, { -14,  57 },
-        { -12,  67 }, { -11,  71 }, { -10,  77 }, { -21,  85 },
-        { -16,  88 }, { -23, 104 }, { -15,  98 }, { -37, 127 },
-        { -10,  82 }, {  -8,  48 }, {  -8,  61 }, {  -8,  66 },
-        {  -7,  70 }, { -14,  75 }, { -10,  79 }, {  -9,  83 },
-        { -12,  92 }, { -18, 108 }, {  -4,  79 }, { -22,  69 },
-        { -16,  75 }, {  -2,  58 }, {   1,  58 }, { -13,  78 },
-        {  -9,  83 }, {  -4,  81 }, { -13,  99 }, { -13,  81 },
-        {  -6,  38 }, { -13,  62 }, {  -6,  58 }, {  -2,  59 },
-        { -16,  73 }, { -10,  76 }, { -13,  86 }, {  -9,  83 },
-        { -10,  87 },
-
-        /* 276 a bit special (not used, x264_cabac_encode_bypass is used instead) */
-        { 0, 0 },
-
-        /* 277 - 337 */
-        { -22, 127 }, { -25, 127 }, { -25, 120 }, { -27, 127 },
-        { -19, 114 }, { -23, 117 }, { -25, 118 }, { -26, 117 },
-        { -24, 113 }, { -28, 118 }, { -31, 120 }, { -37, 124 },
-        { -10,  94 }, { -15, 102 }, { -10,  99 }, { -13, 106 },
-        { -50, 127 }, {  -5,  92 }, {  17,  57 }, {  -5,  86 },
-        { -13,  94 }, { -12,  91 }, {  -2,  77 }, {   0,  71 },
-        {  -1,  73 }, {   4,  64 }, {  -7,  81 }, {   5,  64 },
-        {  15,  57 }, {   1,  67 }, {   0,  68 }, { -10,  67 },
-        {   1,  68 }, {   0,  77 }, {   2,  64 }, {   0,  68 },
-        {  -5,  78 }, {   7,  55 }, {   5,  59 }, {   2,  65 },
-        {  14,  54 }, {  15,  44 }, {   5,  60 }, {   2,  70 },
-        {  -2,  76 }, { -18,  86 }, {  12,  70 }, {   5,  64 },
-        { -12,  70 }, {  11,  55 }, {   5,  56 }, {   0,  69 },
-        {   2,  65 }, {  -6,  74 }, {   5,  54 }, {   7,  54 },
-        {  -6,  76 }, { -11,  82 }, {  -2,  77 }, {  -2,  77 },
-        {  25,  42 },
-
-        /* 338 - 398 */
-        {  17, -13 }, {  16,  -9 }, {  17, -12 }, {  27, -21 },
-        {  37, -30 }, {  41, -40 }, {  42, -41 }, {  48, -47 },
-        {  39, -32 }, {  46, -40 }, {  52, -51 }, {  46, -41 },
-        {  52, -39 }, {  43, -19 }, {  32,  11 }, {  61, -55 },
-        {  56, -46 }, {  62, -50 }, {  81, -67 }, {  45, -20 },
-        {  35,  -2 }, {  28,  15 }, {  34,   1 }, {  39,   1 },
-        {  30,  17 }, {  20,  38 }, {  18,  45 }, {  15,  54 },
-        {   0,  79 }, {  36, -16 }, {  37, -14 }, {  37, -17 },
-        {  32,   1 }, {  34,  15 }, {  29,  15 }, {  24,  25 },
-        {  34,  22 }, {  31,  16 }, {  35,  18 }, {  31,  28 },
-        {  33,  41 }, {  36,  28 }, {  27,  47 }, {  21,  62 },
-        {  18,  31 }, {  19,  26 }, {  36,  24 }, {  24,  23 },
-        {  27,  16 }, {  24,  30 }, {  31,  29 }, {  22,  41 },
-        {  22,  42 }, {  16,  60 }, {  15,  52 }, {  14,  60 },
-        {   3,  78 }, { -16, 123 }, {  21,  53 }, {  22,  56 },
-        {  25,  61 },
-
-        /* 399 -> 435 */
-        {  21,  33 }, {  19,  50 }, {  17,  61 },
-        {  -3,  78 }, {  -8,  74 }, {  -9,  72 }, { -10,  72 },
-        { -18,  75 }, { -12,  71 }, { -11,  63 }, {  -5,  70 },
-        { -17,  75 }, { -14,  72 }, { -16,  67 }, {  -8,  53 },
-        { -14,  59 }, {  -9,  52 }, { -11,  68 }, {   9,  -2 },
-        {  30, -10 }, {  31,  -4 }, {  33,  -1 }, {  33,   7 },
-        {  31,  12 }, {  37,  23 }, {  31,  38 }, {  20,  64 },
-        {  -9,  71 }, {  -7,  37 }, {  -8,  44 }, { -11,  49 },
-        { -10,  56 }, { -12,  59 }, {  -8,  63 }, {  -9,  67 },
-        {  -6,  68 }, { -10,  79 },
-
-        /* 436 -> 459 */
-        {  -3,  78 }, {  -8,  74 }, {  -9,  72 }, { -10,  72 },
-        { -18,  75 }, { -12,  71 }, { -11,  63 }, {  -5,  70 },
-        { -17,  75 }, { -14,  72 }, { -16,  67 }, {  -8,  53 },
-        { -14,  59 }, {  -9,  52 }, { -11,  68 }, {   9,  -2 },
-        {  30, -10 }, {  31,  -4 }, {  33,  -1 }, {  33,   7 },
-        {  31,  12 }, {  37,  23 }, {  31,  38 }, {  20,  64 },
-
-        /* 460 - 1024 */
-        {  11,  80 }, {   5,  76 }, {   2,  84 }, {   5,  78 },
-        {  -6,  55 }, {   4,  61 }, { -14,  83 }, { -37, 127 },
-        {  -5,  79 }, { -11, 104 }, { -11,  91 }, { -30, 127 },
-        {  11,  80 }, {   5,  76 }, {   2,  84 }, {   5,  78 },
-        {  -6,  55 }, {   4,  61 }, { -14,  83 }, { -37, 127 },
-        {  -5,  79 }, { -11, 104 }, { -11,  91 }, { -30, 127 },
-        {  -4,  86 }, { -12,  88 }, {  -5,  82 }, {  -3,  72 },
-        {  -4,  67 }, {  -8,  72 }, { -16,  89 }, {  -9,  69 },
-        {  -1,  59 }, {   5,  66 }, {   4,  57 }, {  -4,  71 },
-        {  -2,  71 }, {   2,  58 }, {  -1,  74 }, {  -4,  44 },
-        {  -1,  69 }, {   0,  62 }, {  -7,  51 }, {  -4,  47 },
-        {  -6,  42 }, {  -3,  41 }, {  -6,  53 }, {   8,  76 },
-        {  -9,  78 }, { -11,  83 }, {   9,  52 }, {   0,  67 },
-        {  -5,  90 }, {   1,  67 }, { -15,  72 }, {  -5,  75 },
-        {  -8,  80 }, { -21,  83 }, { -21,  64 }, { -13,  31 },
-        { -25,  64 }, { -29,  94 }, {   9,  75 }, {  17,  63 },
-        {  -8,  74 }, {  -5,  35 }, {  -2,  27 }, {  13,  91 },
-        {  -4,  86 }, { -12,  88 }, {  -5,  82 }, {  -3,  72 },
-        {  -4,  67 }, {  -8,  72 }, { -16,  89 }, {  -9,  69 },
-        {  -1,  59 }, {   5,  66 }, {   4,  57 }, {  -4,  71 },
-        {  -2,  71 }, {   2,  58 }, {  -1,  74 }, {  -4,  44 },
-        {  -1,  69 }, {   0,  62 }, {  -7,  51 }, {  -4,  47 },
-        {  -6,  42 }, {  -3,  41 }, {  -6,  53 }, {   8,  76 },
-        {  -9,  78 }, { -11,  83 }, {   9,  52 }, {   0,  67 },
-        {  -5,  90 }, {   1,  67 }, { -15,  72 }, {  -5,  75 },
-        {  -8,  80 }, { -21,  83 }, { -21,  64 }, { -13,  31 },
-        { -25,  64 }, { -29,  94 }, {   9,  75 }, {  17,  63 },
-        {  -8,  74 }, {  -5,  35 }, {  -2,  27 }, {  13,  91 },
-        {   4,  39 }, {   0,  42 }, {   7,  34 }, {  11,  29 },
-        {   8,  31 }, {   6,  37 }, {   7,  42 }, {   3,  40 },
-        {   8,  33 }, {  13,  43 }, {  13,  36 }, {   4,  47 },
-        {   3,  55 }, {   2,  58 }, {   6,  60 }, {   8,  44 },
-        {  11,  44 }, {  14,  42 }, {   7,  48 }, {   4,  56 },
-        {   4,  52 }, {  13,  37 }, {   9,  49 }, {  19,  58 },
-        {  10,  48 }, {  12,  45 }, {   0,  69 }, {  20,  33 },
-        {   8,  63 }, {  35, -18 }, {  33, -25 }, {  28,  -3 },
-        {  24,  10 }, {  27,   0 }, {  34, -14 }, {  52, -44 },
-        {  39, -24 }, {  19,  17 }, {  31,  25 }, {  36,  29 },
-        {  24,  33 }, {  34,  15 }, {  30,  20 }, {  22,  73 },
-        {   4,  39 }, {   0,  42 }, {   7,  34 }, {  11,  29 },
-        {   8,  31 }, {   6,  37 }, {   7,  42 }, {   3,  40 },
-        {   8,  33 }, {  13,  43 }, {  13,  36 }, {   4,  47 },
-        {   3,  55 }, {   2,  58 }, {   6,  60 }, {   8,  44 },
-        {  11,  44 }, {  14,  42 }, {   7,  48 }, {   4,  56 },
-        {   4,  52 }, {  13,  37 }, {   9,  49 }, {  19,  58 },
-        {  10,  48 }, {  12,  45 }, {   0,  69 }, {  20,  33 },
-        {   8,  63 }, {  35, -18 }, {  33, -25 }, {  28,  -3 },
-        {  24,  10 }, {  27,   0 }, {  34, -14 }, {  52, -44 },
-        {  39, -24 }, {  19,  17 }, {  31,  25 }, {  36,  29 },
-        {  24,  33 }, {  34,  15 }, {  30,  20 }, {  22,  73 },
-        {  -3,  78 }, {  -8,  74 }, {  -9,  72 }, { -10,  72 },
-        { -18,  75 }, { -12,  71 }, { -11,  63 }, {  -5,  70 },
-        { -17,  75 }, { -14,  72 }, { -16,  67 }, {  -8,  53 },
-        { -14,  59 }, {  -9,  52 }, { -11,  68 }, {  -3,  78 },
-        {  -8,  74 }, {  -9,  72 }, { -10,  72 }, { -18,  75 },
-        { -12,  71 }, { -11,  63 }, {  -5,  70 }, { -17,  75 },
-        { -14,  72 }, { -16,  67 }, {  -8,  53 }, { -14,  59 },
-        {  -9,  52 }, { -11,  68 }, {   9,  -2 }, {  30, -10 },
-        {  31,  -4 }, {  33,  -1 }, {  33,   7 }, {  31,  12 },
-        {  37,  23 }, {  31,  38 }, {  20,  64 }, {   9,  -2 },
-        {  30, -10 }, {  31,  -4 }, {  33,  -1 }, {  33,   7 },
-        {  31,  12 }, {  37,  23 }, {  31,  38 }, {  20,  64 },
-        {  -9,  71 }, {  -7,  37 }, {  -8,  44 }, { -11,  49 },
-        { -10,  56 }, { -12,  59 }, {  -8,  63 }, {  -9,  67 },
-        {  -6,  68 }, { -10,  79 }, {  -3,  78 }, {  -8,  74 },
-        {  -9,  72 }, { -10,  72 }, { -18,  75 }, { -12,  71 },
-        { -11,  63 }, {  -5,  70 }, { -17,  75 }, { -14,  72 },
-        { -16,  67 }, {  -8,  53 }, { -14,  59 }, {  -9,  52 },
-        { -11,  68 }, {  -3,  78 }, {  -8,  74 }, {  -9,  72 },
-        { -10,  72 }, { -18,  75 }, { -12,  71 }, { -11,  63 },
-        {  -5,  70 }, { -17,  75 }, { -14,  72 }, { -16,  67 },
-        {  -8,  53 }, { -14,  59 }, {  -9,  52 }, { -11,  68 },
-        {   9,  -2 }, {  30, -10 }, {  31,  -4 }, {  33,  -1 },
-        {  33,   7 }, {  31,  12 }, {  37,  23 }, {  31,  38 },
-        {  20,  64 }, {   9,  -2 }, {  30, -10 }, {  31,  -4 },
-        {  33,  -1 }, {  33,   7 }, {  31,  12 }, {  37,  23 },
-        {  31,  38 }, {  20,  64 }, {  -9,  71 }, {  -7,  37 },
-        {  -8,  44 }, { -11,  49 }, { -10,  56 }, { -12,  59 },
-        {  -8,  63 }, {  -9,  67 }, {  -6,  68 }, { -10,  79 },
-        { -22, 127 }, { -25, 127 }, { -25, 120 }, { -27, 127 },
-        { -19, 114 }, { -23, 117 }, { -25, 118 }, { -26, 117 },
-        { -24, 113 }, { -28, 118 }, { -31, 120 }, { -37, 124 },
-        { -10,  94 }, { -15, 102 }, { -10,  99 }, { -13, 106 },
-        { -50, 127 }, {  -5,  92 }, {  17,  57 }, {  -5,  86 },
-        { -13,  94 }, { -12,  91 }, {  -2,  77 }, {   0,  71 },
-        {  -1,  73 }, {   4,  64 }, {  -7,  81 }, {   5,  64 },
-        {  15,  57 }, {   1,  67 }, {   0,  68 }, { -10,  67 },
-        {   1,  68 }, {   0,  77 }, {   2,  64 }, {   0,  68 },
-        {  -5,  78 }, {   7,  55 }, {   5,  59 }, {   2,  65 },
-        {  14,  54 }, {  15,  44 }, {   5,  60 }, {   2,  70 },
-        { -22, 127 }, { -25, 127 }, { -25, 120 }, { -27, 127 },
-        { -19, 114 }, { -23, 117 }, { -25, 118 }, { -26, 117 },
-        { -24, 113 }, { -28, 118 }, { -31, 120 }, { -37, 124 },
-        { -10,  94 }, { -15, 102 }, { -10,  99 }, { -13, 106 },
-        { -50, 127 }, {  -5,  92 }, {  17,  57 }, {  -5,  86 },
-        { -13,  94 }, { -12,  91 }, {  -2,  77 }, {   0,  71 },
-        {  -1,  73 }, {   4,  64 }, {  -7,  81 }, {   5,  64 },
-        {  15,  57 }, {   1,  67 }, {   0,  68 }, { -10,  67 },
-        {   1,  68 }, {   0,  77 }, {   2,  64 }, {   0,  68 },
-        {  -5,  78 }, {   7,  55 }, {   5,  59 }, {   2,  65 },
-        {  14,  54 }, {  15,  44 }, {   5,  60 }, {   2,  70 },
-        {  17, -13 }, {  16,  -9 }, {  17, -12 }, {  27, -21 },
-        {  37, -30 }, {  41, -40 }, {  42, -41 }, {  48, -47 },
-        {  39, -32 }, {  46, -40 }, {  52, -51 }, {  46, -41 },
-        {  52, -39 }, {  43, -19 }, {  32,  11 }, {  61, -55 },
-        {  56, -46 }, {  62, -50 }, {  81, -67 }, {  45, -20 },
-        {  35,  -2 }, {  28,  15 }, {  34,   1 }, {  39,   1 },
-        {  30,  17 }, {  20,  38 }, {  18,  45 }, {  15,  54 },
-        {   0,  79 }, {  36, -16 }, {  37, -14 }, {  37, -17 },
-        {  32,   1 }, {  34,  15 }, {  29,  15 }, {  24,  25 },
-        {  34,  22 }, {  31,  16 }, {  35,  18 }, {  31,  28 },
-        {  33,  41 }, {  36,  28 }, {  27,  47 }, {  21,  62 },
-        {  17, -13 }, {  16,  -9 }, {  17, -12 }, {  27, -21 },
-        {  37, -30 }, {  41, -40 }, {  42, -41 }, {  48, -47 },
-        {  39, -32 }, {  46, -40 }, {  52, -51 }, {  46, -41 },
-        {  52, -39 }, {  43, -19 }, {  32,  11 }, {  61, -55 },
-        {  56, -46 }, {  62, -50 }, {  81, -67 }, {  45, -20 },
-        {  35,  -2 }, {  28,  15 }, {  34,   1 }, {  39,   1 },
-        {  30,  17 }, {  20,  38 }, {  18,  45 }, {  15,  54 },
-        {   0,  79 }, {  36, -16 }, {  37, -14 }, {  37, -17 },
-        {  32,   1 }, {  34,  15 }, {  29,  15 }, {  24,  25 },
-        {  34,  22 }, {  31,  16 }, {  35,  18 }, {  31,  28 },
-        {  33,  41 }, {  36,  28 }, {  27,  47 }, {  21,  62 },
-        { -24, 115 }, { -22,  82 }, {  -9,  62 }, {   0,  53 },
-        {   0,  59 }, { -14,  85 }, { -13,  89 }, { -13,  94 },
-        { -11,  92 }, { -29, 127 }, { -21, 100 }, { -14,  57 },
-        { -12,  67 }, { -11,  71 }, { -10,  77 }, { -21,  85 },
-        { -16,  88 }, { -23, 104 }, { -15,  98 }, { -37, 127 },
-        { -10,  82 }, {  -8,  48 }, {  -8,  61 }, {  -8,  66 },
-        {  -7,  70 }, { -14,  75 }, { -10,  79 }, {  -9,  83 },
-        { -12,  92 }, { -18, 108 }, { -24, 115 }, { -22,  82 },
-        {  -9,  62 }, {   0,  53 }, {   0,  59 }, { -14,  85 },
-        { -13,  89 }, { -13,  94 }, { -11,  92 }, { -29, 127 },
-        { -21, 100 }, { -14,  57 }, { -12,  67 }, { -11,  71 },
-        { -10,  77 }, { -21,  85 }, { -16,  88 }, { -23, 104 },
-        { -15,  98 }, { -37, 127 }, { -10,  82 }, {  -8,  48 },
-        {  -8,  61 }, {  -8,  66 }, {  -7,  70 }, { -14,  75 },
-        { -10,  79 }, {  -9,  83 }, { -12,  92 }, { -18, 108 },
-        {  -5,  79 }, { -11, 104 }, { -11,  91 }, { -30, 127 },
-        {  -5,  79 }, { -11, 104 }, { -11,  91 }, { -30, 127 },
-        {  -5,  79 }, { -11, 104 }, { -11,  91 }, { -30, 127 }
-    }
-};
-
-const uint8_t x264_cabac_range_lps[64][4] =
-{
-    {  2,   2,   2,   2}, {  6,   7,   8,   9}, {  6,   7,   9,  10}, {  6,   8,   9,  11},
-    {  7,   8,  10,  11}, {  7,   9,  10,  12}, {  7,   9,  11,  12}, {  8,   9,  11,  13},
-    {  8,  10,  12,  14}, {  9,  11,  12,  14}, {  9,  11,  13,  15}, { 10,  12,  14,  16},
-    { 10,  12,  15,  17}, { 11,  13,  15,  18}, { 11,  14,  16,  19}, { 12,  14,  17,  20},
-    { 12,  15,  18,  21}, { 13,  16,  19,  22}, { 14,  17,  20,  23}, { 14,  18,  21,  24},
-    { 15,  19,  22,  25}, { 16,  20,  23,  27}, { 17,  21,  25,  28}, { 18,  22,  26,  30},
-    { 19,  23,  27,  31}, { 20,  24,  29,  33}, { 21,  26,  30,  35}, { 22,  27,  32,  37},
-    { 23,  28,  33,  39}, { 24,  30,  35,  41}, { 26,  31,  37,  43}, { 27,  33,  39,  45},
-    { 29,  35,  41,  48}, { 30,  37,  43,  50}, { 32,  39,  46,  53}, { 33,  41,  48,  56},
-    { 35,  43,  51,  59}, { 37,  45,  54,  62}, { 39,  48,  56,  65}, { 41,  50,  59,  69},
-    { 43,  53,  63,  72}, { 46,  56,  66,  76}, { 48,  59,  69,  80}, { 51,  62,  73,  85},
-    { 53,  65,  77,  89}, { 56,  69,  81,  94}, { 59,  72,  86,  99}, { 62,  76,  90, 104},
-    { 66,  80,  95, 110}, { 69,  85, 100, 116}, { 73,  89, 105, 122}, { 77,  94, 111, 128},
-    { 81,  99, 117, 135}, { 85, 104, 123, 142}, { 90, 110, 130, 150}, { 95, 116, 137, 158},
-    {100, 122, 144, 166}, {105, 128, 152, 175}, {111, 135, 160, 185}, {116, 142, 169, 195},
-    {123, 150, 178, 205}, {128, 158, 187, 216}, {128, 167, 197, 227}, {128, 176, 208, 240}
-};
-
-const uint8_t x264_cabac_transition[128][2] =
-{
-    {  0,   0}, {  1,   1}, {  2,  50}, { 51,   3}, {  2,  50}, { 51,   3}, {  4,  52}, { 53,   5},
-    {  6,  52}, { 53,   7}, {  8,  52}, { 53,   9}, { 10,  54}, { 55,  11}, { 12,  54}, { 55,  13},
-    { 14,  54}, { 55,  15}, { 16,  56}, { 57,  17}, { 18,  56}, { 57,  19}, { 20,  56}, { 57,  21},
-    { 22,  58}, { 59,  23}, { 24,  58}, { 59,  25}, { 26,  60}, { 61,  27}, { 28,  60}, { 61,  29},
-    { 30,  60}, { 61,  31}, { 32,  62}, { 63,  33}, { 34,  62}, { 63,  35}, { 36,  64}, { 65,  37},
-    { 38,  66}, { 67,  39}, { 40,  66}, { 67,  41}, { 42,  66}, { 67,  43}, { 44,  68}, { 69,  45},
-    { 46,  68}, { 69,  47}, { 48,  70}, { 71,  49}, { 50,  72}, { 73,  51}, { 52,  72}, { 73,  53},
-    { 54,  74}, { 75,  55}, { 56,  74}, { 75,  57}, { 58,  76}, { 77,  59}, { 60,  78}, { 79,  61},
-    { 62,  78}, { 79,  63}, { 64,  80}, { 81,  65}, { 66,  82}, { 83,  67}, { 68,  82}, { 83,  69},
-    { 70,  84}, { 85,  71}, { 72,  84}, { 85,  73}, { 74,  88}, { 89,  75}, { 76,  88}, { 89,  77},
-    { 78,  90}, { 91,  79}, { 80,  90}, { 91,  81}, { 82,  94}, { 95,  83}, { 84,  94}, { 95,  85},
-    { 86,  96}, { 97,  87}, { 88,  96}, { 97,  89}, { 90, 100}, {101,  91}, { 92, 100}, {101,  93},
-    { 94, 102}, {103,  95}, { 96, 104}, {105,  97}, { 98, 104}, {105,  99}, {100, 108}, {109, 101},
-    {102, 108}, {109, 103}, {104, 110}, {111, 105}, {106, 112}, {113, 107}, {108, 114}, {115, 109},
-    {110, 116}, {117, 111}, {112, 118}, {119, 113}, {114, 118}, {119, 115}, {116, 122}, {123, 117},
-    {118, 122}, {123, 119}, {120, 124}, {125, 121}, {122, 126}, {127, 123}, {124, 127}, {126, 125}
-};
-
-const uint8_t x264_cabac_renorm_shift[64] =
-{
-    6,5,4,4,3,3,3,3,2,2,2,2,2,2,2,2,
-    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-};
-
-/* -ln2(probability) */
-const uint16_t x264_cabac_entropy[128] =
-{
-    FIX8(0.0273), FIX8(5.7370), FIX8(0.0288), FIX8(5.6618),
-    FIX8(0.0303), FIX8(5.5866), FIX8(0.0320), FIX8(5.5114),
-    FIX8(0.0337), FIX8(5.4362), FIX8(0.0355), FIX8(5.3610),
-    FIX8(0.0375), FIX8(5.2859), FIX8(0.0395), FIX8(5.2106),
-    FIX8(0.0416), FIX8(5.1354), FIX8(0.0439), FIX8(5.0602),
-    FIX8(0.0463), FIX8(4.9851), FIX8(0.0488), FIX8(4.9099),
-    FIX8(0.0515), FIX8(4.8347), FIX8(0.0543), FIX8(4.7595),
-    FIX8(0.0572), FIX8(4.6843), FIX8(0.0604), FIX8(4.6091),
-    FIX8(0.0637), FIX8(4.5339), FIX8(0.0671), FIX8(4.4588),
-    FIX8(0.0708), FIX8(4.3836), FIX8(0.0747), FIX8(4.3083),
-    FIX8(0.0788), FIX8(4.2332), FIX8(0.0832), FIX8(4.1580),
-    FIX8(0.0878), FIX8(4.0828), FIX8(0.0926), FIX8(4.0076),
-    FIX8(0.0977), FIX8(3.9324), FIX8(0.1032), FIX8(3.8572),
-    FIX8(0.1089), FIX8(3.7820), FIX8(0.1149), FIX8(3.7068),
-    FIX8(0.1214), FIX8(3.6316), FIX8(0.1282), FIX8(3.5565),
-    FIX8(0.1353), FIX8(3.4813), FIX8(0.1429), FIX8(3.4061),
-    FIX8(0.1510), FIX8(3.3309), FIX8(0.1596), FIX8(3.2557),
-    FIX8(0.1686), FIX8(3.1805), FIX8(0.1782), FIX8(3.1053),
-    FIX8(0.1884), FIX8(3.0301), FIX8(0.1992), FIX8(2.9549),
-    FIX8(0.2107), FIX8(2.8797), FIX8(0.2229), FIX8(2.8046),
-    FIX8(0.2358), FIX8(2.7294), FIX8(0.2496), FIX8(2.6542),
-    FIX8(0.2642), FIX8(2.5790), FIX8(0.2798), FIX8(2.5038),
-    FIX8(0.2964), FIX8(2.4286), FIX8(0.3142), FIX8(2.3534),
-    FIX8(0.3331), FIX8(2.2782), FIX8(0.3532), FIX8(2.2030),
-    FIX8(0.3748), FIX8(2.1278), FIX8(0.3979), FIX8(2.0527),
-    FIX8(0.4226), FIX8(1.9775), FIX8(0.4491), FIX8(1.9023),
-    FIX8(0.4776), FIX8(1.8271), FIX8(0.5082), FIX8(1.7519),
-    FIX8(0.5412), FIX8(1.6767), FIX8(0.5768), FIX8(1.6015),
-    FIX8(0.6152), FIX8(1.5263), FIX8(0.6568), FIX8(1.4511),
-    FIX8(0.7020), FIX8(1.3759), FIX8(0.7513), FIX8(1.3008),
-    FIX8(0.8050), FIX8(1.2256), FIX8(0.8638), FIX8(1.1504),
-    FIX8(0.9285), FIX8(1.0752), FIX8(1.0000), FIX8(1.0000)
-};
-
 static uint8_t cabac_contexts[4][QP_MAX_SPEC+1][1024];
 
 void x264_cabac_init( x264_t *h )
@@ -1332,8 +34,8 @@ void x264_cabac_init( x264_t *h )
     int ctx_count = CHROMA444 ? 1024 : 460;
     for( int i = 0; i < 4; i++ )
     {
-        const int8_t (*cabac_context_init)[1024][2] = i == 0 ? &cabac_context_init_I
-                                                             : &cabac_context_init_PB[i-1];
+        const int8_t (*cabac_context_init)[1024][2] = i == 0 ? &x264_cabac_context_init_I
+                                                             : &x264_cabac_context_init_PB[i-1];
         for( int qp = 0; qp <= QP_MAX_SPEC; qp++ )
             for( int j = 0; j < ctx_count; j++ )
             {
index 13788342b5e33cbc13ac0ba7dab3cd036ba9d5f7..af6d5c688f7f00a73197b3cbe427c9c5219c3129 100644 (file)
@@ -51,21 +51,29 @@ typedef struct
     uint8_t padding[12];
 } x264_cabac_t;
 
-extern const uint8_t x264_cabac_transition[128][2];
-extern const uint16_t x264_cabac_entropy[128];
-
 /* init the contexts given i_slice_type, the quantif and the model */
+#define x264_cabac_context_init x264_template(cabac_context_init)
 void x264_cabac_context_init( x264_t *h, x264_cabac_t *cb, int i_slice_type, int i_qp, int i_model );
 
+#define x264_cabac_encode_init_core x264_template(cabac_encode_init_core)
 void x264_cabac_encode_init_core( x264_cabac_t *cb );
+#define x264_cabac_encode_init x264_template(cabac_encode_init)
 void x264_cabac_encode_init( x264_cabac_t *cb, uint8_t *p_data, uint8_t *p_end );
+#define x264_cabac_encode_decision_c x264_template(cabac_encode_decision_c)
 void x264_cabac_encode_decision_c( x264_cabac_t *cb, int i_ctx, int b );
+#define x264_cabac_encode_decision_asm x264_template(cabac_encode_decision_asm)
 void x264_cabac_encode_decision_asm( x264_cabac_t *cb, int i_ctx, int b );
+#define x264_cabac_encode_bypass_c x264_template(cabac_encode_bypass_c)
 void x264_cabac_encode_bypass_c( x264_cabac_t *cb, int b );
+#define x264_cabac_encode_bypass_asm x264_template(cabac_encode_bypass_asm)
 void x264_cabac_encode_bypass_asm( x264_cabac_t *cb, int b );
+#define x264_cabac_encode_terminal_c x264_template(cabac_encode_terminal_c)
 void x264_cabac_encode_terminal_c( x264_cabac_t *cb );
+#define x264_cabac_encode_terminal_asm x264_template(cabac_encode_terminal_asm)
 void x264_cabac_encode_terminal_asm( x264_cabac_t *cb );
+#define x264_cabac_encode_ue_bypass x264_template(cabac_encode_ue_bypass)
 void x264_cabac_encode_ue_bypass( x264_cabac_t *cb, int exp_bits, int val );
+#define x264_cabac_encode_flush x264_template(cabac_encode_flush)
 void x264_cabac_encode_flush( x264_t *h, x264_cabac_t *cb );
 
 #if HAVE_MMX
index e4a7e3a8e35650a1a9a75c64f5370fd028e220a6..87a6844fa5c8c2ed9960c43ee40fd1eebbe589ad 100644 (file)
 
 #include "common.h"
 
-#include <ctype.h>
-
-#if HAVE_MALLOC_H
-#include <malloc.h>
-#endif
-#if HAVE_THP
-#include <sys/mman.h>
-#endif
-
-const int x264_bit_depth = BIT_DEPTH;
-
-const int x264_chroma_format = X264_CHROMA_FORMAT;
-
-static void log_default( void *, int, const char *, va_list );
-
-/****************************************************************************
- * x264_param_default:
- ****************************************************************************/
-void x264_param_default( x264_param_t *param )
-{
-    /* */
-    memset( param, 0, sizeof( x264_param_t ) );
-
-    /* CPU autodetect */
-    param->cpu = x264_cpu_detect();
-    param->i_threads = X264_THREADS_AUTO;
-    param->i_lookahead_threads = X264_THREADS_AUTO;
-    param->b_deterministic = 1;
-    param->i_sync_lookahead = X264_SYNC_LOOKAHEAD_AUTO;
-
-    /* Video properties */
-    param->i_csp           = X264_CHROMA_FORMAT ? X264_CHROMA_FORMAT : X264_CSP_I420;
-    param->i_width         = 0;
-    param->i_height        = 0;
-    param->vui.i_sar_width = 0;
-    param->vui.i_sar_height= 0;
-    param->vui.i_overscan  = 0;  /* undef */
-    param->vui.i_vidformat = 5;  /* undef */
-    param->vui.b_fullrange = -1; /* default depends on input */
-    param->vui.i_colorprim = 2;  /* undef */
-    param->vui.i_transfer  = 2;  /* undef */
-    param->vui.i_colmatrix = -1; /* default depends on input */
-    param->vui.i_chroma_loc= 0;  /* left center */
-    param->i_fps_num       = 25;
-    param->i_fps_den       = 1;
-    param->i_level_idc     = -1;
-    param->i_slice_max_size = 0;
-    param->i_slice_max_mbs = 0;
-    param->i_slice_count = 0;
-
-    /* Encoder parameters */
-    param->i_frame_reference = 3;
-    param->i_keyint_max = 250;
-    param->i_keyint_min = X264_KEYINT_MIN_AUTO;
-    param->i_bframe = 3;
-    param->i_scenecut_threshold = 40;
-    param->i_bframe_adaptive = X264_B_ADAPT_FAST;
-    param->i_bframe_bias = 0;
-    param->i_bframe_pyramid = X264_B_PYRAMID_NORMAL;
-    param->b_interlaced = 0;
-    param->b_constrained_intra = 0;
-
-    param->b_deblocking_filter = 1;
-    param->i_deblocking_filter_alphac0 = 0;
-    param->i_deblocking_filter_beta = 0;
-
-    param->b_cabac = 1;
-    param->i_cabac_init_idc = 0;
-
-    param->rc.i_rc_method = X264_RC_CRF;
-    param->rc.i_bitrate = 0;
-    param->rc.f_rate_tolerance = 1.0;
-    param->rc.i_vbv_max_bitrate = 0;
-    param->rc.i_vbv_buffer_size = 0;
-    param->rc.f_vbv_buffer_init = 0.9;
-    param->rc.i_qp_constant = -1;
-    param->rc.f_rf_constant = 23;
-    param->rc.i_qp_min = 0;
-    param->rc.i_qp_max = INT_MAX;
-    param->rc.i_qp_step = 4;
-    param->rc.f_ip_factor = 1.4;
-    param->rc.f_pb_factor = 1.3;
-    param->rc.i_aq_mode = X264_AQ_VARIANCE;
-    param->rc.f_aq_strength = 1.0;
-    param->rc.i_lookahead = 40;
-
-    param->rc.b_stat_write = 0;
-    param->rc.psz_stat_out = "x264_2pass.log";
-    param->rc.b_stat_read = 0;
-    param->rc.psz_stat_in = "x264_2pass.log";
-    param->rc.f_qcompress = 0.6;
-    param->rc.f_qblur = 0.5;
-    param->rc.f_complexity_blur = 20;
-    param->rc.i_zones = 0;
-    param->rc.b_mb_tree = 1;
-
-    /* Log */
-    param->pf_log = log_default;
-    param->p_log_private = NULL;
-    param->i_log_level = X264_LOG_INFO;
-
-    /* */
-    param->analyse.intra = X264_ANALYSE_I4x4 | X264_ANALYSE_I8x8;
-    param->analyse.inter = X264_ANALYSE_I4x4 | X264_ANALYSE_I8x8
-                         | X264_ANALYSE_PSUB16x16 | X264_ANALYSE_BSUB16x16;
-    param->analyse.i_direct_mv_pred = X264_DIRECT_PRED_SPATIAL;
-    param->analyse.i_me_method = X264_ME_HEX;
-    param->analyse.f_psy_rd = 1.0;
-    param->analyse.b_psy = 1;
-    param->analyse.f_psy_trellis = 0;
-    param->analyse.i_me_range = 16;
-    param->analyse.i_subpel_refine = 7;
-    param->analyse.b_mixed_references = 1;
-    param->analyse.b_chroma_me = 1;
-    param->analyse.i_mv_range_thread = -1;
-    param->analyse.i_mv_range = -1; // set from level_idc
-    param->analyse.i_chroma_qp_offset = 0;
-    param->analyse.b_fast_pskip = 1;
-    param->analyse.b_weighted_bipred = 1;
-    param->analyse.i_weighted_pred = X264_WEIGHTP_SMART;
-    param->analyse.b_dct_decimate = 1;
-    param->analyse.b_transform_8x8 = 1;
-    param->analyse.i_trellis = 1;
-    param->analyse.i_luma_deadzone[0] = 21;
-    param->analyse.i_luma_deadzone[1] = 11;
-    param->analyse.b_psnr = 0;
-    param->analyse.b_ssim = 0;
-
-    param->i_cqm_preset = X264_CQM_FLAT;
-    memset( param->cqm_4iy, 16, sizeof( param->cqm_4iy ) );
-    memset( param->cqm_4py, 16, sizeof( param->cqm_4py ) );
-    memset( param->cqm_4ic, 16, sizeof( param->cqm_4ic ) );
-    memset( param->cqm_4pc, 16, sizeof( param->cqm_4pc ) );
-    memset( param->cqm_8iy, 16, sizeof( param->cqm_8iy ) );
-    memset( param->cqm_8py, 16, sizeof( param->cqm_8py ) );
-    memset( param->cqm_8ic, 16, sizeof( param->cqm_8ic ) );
-    memset( param->cqm_8pc, 16, sizeof( param->cqm_8pc ) );
-
-    param->b_repeat_headers = 1;
-    param->b_annexb = 1;
-    param->b_aud = 0;
-    param->b_vfr_input = 1;
-    param->i_nal_hrd = X264_NAL_HRD_NONE;
-    param->b_tff = 1;
-    param->b_pic_struct = 0;
-    param->b_fake_interlaced = 0;
-    param->i_frame_packing = -1;
-    param->b_opencl = 0;
-    param->i_opencl_device = 0;
-    param->opencl_device_id = NULL;
-    param->psz_clbin_file = NULL;
-}
-
-static int param_apply_preset( x264_param_t *param, const char *preset )
-{
-    char *end;
-    int i = strtol( preset, &end, 10 );
-    if( *end == 0 && i >= 0 && i < sizeof(x264_preset_names)/sizeof(*x264_preset_names)-1 )
-        preset = x264_preset_names[i];
-
-    if( !strcasecmp( preset, "ultrafast" ) )
-    {
-        param->i_frame_reference = 1;
-        param->i_scenecut_threshold = 0;
-        param->b_deblocking_filter = 0;
-        param->b_cabac = 0;
-        param->i_bframe = 0;
-        param->analyse.intra = 0;
-        param->analyse.inter = 0;
-        param->analyse.b_transform_8x8 = 0;
-        param->analyse.i_me_method = X264_ME_DIA;
-        param->analyse.i_subpel_refine = 0;
-        param->rc.i_aq_mode = 0;
-        param->analyse.b_mixed_references = 0;
-        param->analyse.i_trellis = 0;
-        param->i_bframe_adaptive = X264_B_ADAPT_NONE;
-        param->rc.b_mb_tree = 0;
-        param->analyse.i_weighted_pred = X264_WEIGHTP_NONE;
-        param->analyse.b_weighted_bipred = 0;
-        param->rc.i_lookahead = 0;
-    }
-    else if( !strcasecmp( preset, "superfast" ) )
-    {
-        param->analyse.inter = X264_ANALYSE_I8x8|X264_ANALYSE_I4x4;
-        param->analyse.i_me_method = X264_ME_DIA;
-        param->analyse.i_subpel_refine = 1;
-        param->i_frame_reference = 1;
-        param->analyse.b_mixed_references = 0;
-        param->analyse.i_trellis = 0;
-        param->rc.b_mb_tree = 0;
-        param->analyse.i_weighted_pred = X264_WEIGHTP_SIMPLE;
-        param->rc.i_lookahead = 0;
-    }
-    else if( !strcasecmp( preset, "veryfast" ) )
-    {
-        param->analyse.i_subpel_refine = 2;
-        param->i_frame_reference = 1;
-        param->analyse.b_mixed_references = 0;
-        param->analyse.i_trellis = 0;
-        param->analyse.i_weighted_pred = X264_WEIGHTP_SIMPLE;
-        param->rc.i_lookahead = 10;
-    }
-    else if( !strcasecmp( preset, "faster" ) )
-    {
-        param->analyse.b_mixed_references = 0;
-        param->i_frame_reference = 2;
-        param->analyse.i_subpel_refine = 4;
-        param->analyse.i_weighted_pred = X264_WEIGHTP_SIMPLE;
-        param->rc.i_lookahead = 20;
-    }
-    else if( !strcasecmp( preset, "fast" ) )
-    {
-        param->i_frame_reference = 2;
-        param->analyse.i_subpel_refine = 6;
-        param->analyse.i_weighted_pred = X264_WEIGHTP_SIMPLE;
-        param->rc.i_lookahead = 30;
-    }
-    else if( !strcasecmp( preset, "medium" ) )
-    {
-        /* Default is medium */
-    }
-    else if( !strcasecmp( preset, "slow" ) )
-    {
-        param->analyse.i_subpel_refine = 8;
-        param->i_frame_reference = 5;
-        param->analyse.i_direct_mv_pred = X264_DIRECT_PRED_AUTO;
-        param->analyse.i_trellis = 2;
-        param->rc.i_lookahead = 50;
-    }
-    else if( !strcasecmp( preset, "slower" ) )
-    {
-        param->analyse.i_me_method = X264_ME_UMH;
-        param->analyse.i_subpel_refine = 9;
-        param->i_frame_reference = 8;
-        param->i_bframe_adaptive = X264_B_ADAPT_TRELLIS;
-        param->analyse.i_direct_mv_pred = X264_DIRECT_PRED_AUTO;
-        param->analyse.inter |= X264_ANALYSE_PSUB8x8;
-        param->analyse.i_trellis = 2;
-        param->rc.i_lookahead = 60;
-    }
-    else if( !strcasecmp( preset, "veryslow" ) )
-    {
-        param->analyse.i_me_method = X264_ME_UMH;
-        param->analyse.i_subpel_refine = 10;
-        param->analyse.i_me_range = 24;
-        param->i_frame_reference = 16;
-        param->i_bframe_adaptive = X264_B_ADAPT_TRELLIS;
-        param->analyse.i_direct_mv_pred = X264_DIRECT_PRED_AUTO;
-        param->analyse.inter |= X264_ANALYSE_PSUB8x8;
-        param->analyse.i_trellis = 2;
-        param->i_bframe = 8;
-        param->rc.i_lookahead = 60;
-    }
-    else if( !strcasecmp( preset, "placebo" ) )
-    {
-        param->analyse.i_me_method = X264_ME_TESA;
-        param->analyse.i_subpel_refine = 11;
-        param->analyse.i_me_range = 24;
-        param->i_frame_reference = 16;
-        param->i_bframe_adaptive = X264_B_ADAPT_TRELLIS;
-        param->analyse.i_direct_mv_pred = X264_DIRECT_PRED_AUTO;
-        param->analyse.inter |= X264_ANALYSE_PSUB8x8;
-        param->analyse.b_fast_pskip = 0;
-        param->analyse.i_trellis = 2;
-        param->i_bframe = 16;
-        param->rc.i_lookahead = 60;
-    }
-    else
-    {
-        x264_log( NULL, X264_LOG_ERROR, "invalid preset '%s'\n", preset );
-        return -1;
-    }
-    return 0;
-}
-
-static int param_apply_tune( x264_param_t *param, const char *tune )
-{
-    char *tmp = x264_malloc( strlen( tune ) + 1 );
-    if( !tmp )
-        return -1;
-    tmp = strcpy( tmp, tune );
-    char *s = strtok( tmp, ",./-+" );
-    int psy_tuning_used = 0;
-    while( s )
-    {
-        if( !strncasecmp( s, "film", 4 ) )
-        {
-            if( psy_tuning_used++ ) goto psy_failure;
-            param->i_deblocking_filter_alphac0 = -1;
-            param->i_deblocking_filter_beta = -1;
-            param->analyse.f_psy_trellis = 0.15;
-        }
-        else if( !strncasecmp( s, "animation", 9 ) )
-        {
-            if( psy_tuning_used++ ) goto psy_failure;
-            param->i_frame_reference = param->i_frame_reference > 1 ? param->i_frame_reference*2 : 1;
-            param->i_deblocking_filter_alphac0 = 1;
-            param->i_deblocking_filter_beta = 1;
-            param->analyse.f_psy_rd = 0.4;
-            param->rc.f_aq_strength = 0.6;
-            param->i_bframe += 2;
-        }
-        else if( !strncasecmp( s, "grain", 5 ) )
-        {
-            if( psy_tuning_used++ ) goto psy_failure;
-            param->i_deblocking_filter_alphac0 = -2;
-            param->i_deblocking_filter_beta = -2;
-            param->analyse.f_psy_trellis = 0.25;
-            param->analyse.b_dct_decimate = 0;
-            param->rc.f_pb_factor = 1.1;
-            param->rc.f_ip_factor = 1.1;
-            param->rc.f_aq_strength = 0.5;
-            param->analyse.i_luma_deadzone[0] = 6;
-            param->analyse.i_luma_deadzone[1] = 6;
-            param->rc.f_qcompress = 0.8;
-        }
-        else if( !strncasecmp( s, "stillimage", 10 ) )
-        {
-            if( psy_tuning_used++ ) goto psy_failure;
-            param->i_deblocking_filter_alphac0 = -3;
-            param->i_deblocking_filter_beta = -3;
-            param->analyse.f_psy_rd = 2.0;
-            param->analyse.f_psy_trellis = 0.7;
-            param->rc.f_aq_strength = 1.2;
-        }
-        else if( !strncasecmp( s, "psnr", 4 ) )
-        {
-            if( psy_tuning_used++ ) goto psy_failure;
-            param->rc.i_aq_mode = X264_AQ_NONE;
-            param->analyse.b_psy = 0;
-        }
-        else if( !strncasecmp( s, "ssim", 4 ) )
-        {
-            if( psy_tuning_used++ ) goto psy_failure;
-            param->rc.i_aq_mode = X264_AQ_AUTOVARIANCE;
-            param->analyse.b_psy = 0;
-        }
-        else if( !strncasecmp( s, "fastdecode", 10 ) )
-        {
-            param->b_deblocking_filter = 0;
-            param->b_cabac = 0;
-            param->analyse.b_weighted_bipred = 0;
-            param->analyse.i_weighted_pred = X264_WEIGHTP_NONE;
-        }
-        else if( !strncasecmp( s, "zerolatency", 11 ) )
-        {
-            param->rc.i_lookahead = 0;
-            param->i_sync_lookahead = 0;
-            param->i_bframe = 0;
-            param->b_sliced_threads = 1;
-            param->b_vfr_input = 0;
-            param->rc.b_mb_tree = 0;
-        }
-        else if( !strncasecmp( s, "touhou", 6 ) )
-        {
-            if( psy_tuning_used++ ) goto psy_failure;
-            param->i_frame_reference = param->i_frame_reference > 1 ? param->i_frame_reference*2 : 1;
-            param->i_deblocking_filter_alphac0 = -1;
-            param->i_deblocking_filter_beta = -1;
-            param->analyse.f_psy_trellis = 0.2;
-            param->rc.f_aq_strength = 1.3;
-            if( param->analyse.inter & X264_ANALYSE_PSUB16x16 )
-                param->analyse.inter |= X264_ANALYSE_PSUB8x8;
-        }
-        else
-        {
-            x264_log( NULL, X264_LOG_ERROR, "invalid tune '%s'\n", s );
-            x264_free( tmp );
-            return -1;
-        }
-        if( 0 )
-        {
-    psy_failure:
-            x264_log( NULL, X264_LOG_WARNING, "only 1 psy tuning can be used: ignoring tune %s\n", s );
-        }
-        s = strtok( NULL, ",./-+" );
-    }
-    x264_free( tmp );
-    return 0;
-}
-
-int x264_param_default_preset( x264_param_t *param, const char *preset, const char *tune )
-{
-    x264_param_default( param );
-
-    if( preset && param_apply_preset( param, preset ) < 0 )
-        return -1;
-    if( tune && param_apply_tune( param, tune ) < 0 )
-        return -1;
-    return 0;
-}
-
-void x264_param_apply_fastfirstpass( x264_param_t *param )
-{
-    /* Set faster options in case of turbo firstpass. */
-    if( param->rc.b_stat_write && !param->rc.b_stat_read )
-    {
-        param->i_frame_reference = 1;
-        param->analyse.b_transform_8x8 = 0;
-        param->analyse.inter = 0;
-        param->analyse.i_me_method = X264_ME_DIA;
-        param->analyse.i_subpel_refine = X264_MIN( 2, param->analyse.i_subpel_refine );
-        param->analyse.i_trellis = 0;
-        param->analyse.b_fast_pskip = 1;
-    }
-}
-
-static int profile_string_to_int( const char *str )
-{
-    if( !strcasecmp( str, "baseline" ) )
-        return PROFILE_BASELINE;
-    if( !strcasecmp( str, "main" ) )
-        return PROFILE_MAIN;
-    if( !strcasecmp( str, "high" ) )
-        return PROFILE_HIGH;
-    if( !strcasecmp( str, "high10" ) )
-        return PROFILE_HIGH10;
-    if( !strcasecmp( str, "high422" ) )
-        return PROFILE_HIGH422;
-    if( !strcasecmp( str, "high444" ) )
-        return PROFILE_HIGH444_PREDICTIVE;
-    return -1;
-}
-
-int x264_param_apply_profile( x264_param_t *param, const char *profile )
-{
-    if( !profile )
-        return 0;
-
-    int p = profile_string_to_int( profile );
-    if( p < 0 )
-    {
-        x264_log( NULL, X264_LOG_ERROR, "invalid profile: %s\n", profile );
-        return -1;
-    }
-    if( p < PROFILE_HIGH444_PREDICTIVE && ((param->rc.i_rc_method == X264_RC_CQP && param->rc.i_qp_constant <= 0) ||
-        (param->rc.i_rc_method == X264_RC_CRF && (int)(param->rc.f_rf_constant + QP_BD_OFFSET) <= 0)) )
-    {
-        x264_log( NULL, X264_LOG_ERROR, "%s profile doesn't support lossless\n", profile );
-        return -1;
-    }
-    if( p < PROFILE_HIGH444_PREDICTIVE && (param->i_csp & X264_CSP_MASK) >= X264_CSP_I444 )
-    {
-        x264_log( NULL, X264_LOG_ERROR, "%s profile doesn't support 4:4:4\n", profile );
-        return -1;
-    }
-    if( p < PROFILE_HIGH422 && (param->i_csp & X264_CSP_MASK) >= X264_CSP_I422 )
-    {
-        x264_log( NULL, X264_LOG_ERROR, "%s profile doesn't support 4:2:2\n", profile );
-        return -1;
-    }
-    if( p < PROFILE_HIGH10 && BIT_DEPTH > 8 )
-    {
-        x264_log( NULL, X264_LOG_ERROR, "%s profile doesn't support a bit depth of %d\n", profile, BIT_DEPTH );
-        return -1;
-    }
-
-    if( p == PROFILE_BASELINE )
-    {
-        param->analyse.b_transform_8x8 = 0;
-        param->b_cabac = 0;
-        param->i_cqm_preset = X264_CQM_FLAT;
-        param->psz_cqm_file = NULL;
-        param->i_bframe = 0;
-        param->analyse.i_weighted_pred = X264_WEIGHTP_NONE;
-        if( param->b_interlaced )
-        {
-            x264_log( NULL, X264_LOG_ERROR, "baseline profile doesn't support interlacing\n" );
-            return -1;
-        }
-        if( param->b_fake_interlaced )
-        {
-            x264_log( NULL, X264_LOG_ERROR, "baseline profile doesn't support fake interlacing\n" );
-            return -1;
-        }
-    }
-    else if( p == PROFILE_MAIN )
-    {
-        param->analyse.b_transform_8x8 = 0;
-        param->i_cqm_preset = X264_CQM_FLAT;
-        param->psz_cqm_file = NULL;
-    }
-    return 0;
-}
-
-static int parse_enum( const char *arg, const char * const *names, int *dst )
-{
-    for( int i = 0; names[i]; i++ )
-        if( !strcasecmp( arg, names[i] ) )
-        {
-            *dst = i;
-            return 0;
-        }
-    return -1;
-}
-
-static int parse_cqm( const char *str, uint8_t *cqm, int length )
-{
-    int i = 0;
-    do {
-        int coef;
-        if( !sscanf( str, "%d", &coef ) || coef < 1 || coef > 255 )
-            return -1;
-        cqm[i++] = coef;
-    } while( i < length && (str = strchr( str, ',' )) && str++ );
-    return (i == length) ? 0 : -1;
-}
-
-static int atobool_internal( const char *str, int *b_error )
-{
-    if( !strcmp(str, "1") ||
-        !strcasecmp(str, "true") ||
-        !strcasecmp(str, "yes") )
-        return 1;
-    if( !strcmp(str, "0") ||
-        !strcasecmp(str, "false") ||
-        !strcasecmp(str, "no") )
-        return 0;
-    *b_error = 1;
-    return 0;
-}
-
-static int atoi_internal( const char *str, int *b_error )
-{
-    char *end;
-    int v = strtol( str, &end, 0 );
-    if( end == str || *end != '\0' )
-        *b_error = 1;
-    return v;
-}
-
-static double atof_internal( const char *str, int *b_error )
-{
-    char *end;
-    double v = strtod( str, &end );
-    if( end == str || *end != '\0' )
-        *b_error = 1;
-    return v;
-}
-
-#define atobool(str) ( name_was_bool = 1, atobool_internal( str, &b_error ) )
-#undef atoi
-#undef atof
-#define atoi(str) atoi_internal( str, &b_error )
-#define atof(str) atof_internal( str, &b_error )
-
-int x264_param_parse( x264_param_t *p, const char *name, const char *value )
-{
-    char *name_buf = NULL;
-    int b_error = 0;
-    int errortype = X264_PARAM_BAD_VALUE;
-    int name_was_bool;
-    int value_was_null = !value;
-
-    if( !name )
-        return X264_PARAM_BAD_NAME;
-    if( !value )
-        value = "true";
-
-    if( value[0] == '=' )
-        value++;
-
-    if( strchr( name, '_' ) ) // s/_/-/g
-    {
-        char *c;
-        name_buf = strdup(name);
-        if( !name_buf )
-            return X264_PARAM_BAD_NAME;
-        while( (c = strchr( name_buf, '_' )) )
-            *c = '-';
-        name = name_buf;
-    }
-
-    if( !strncmp( name, "no", 2 ) )
-    {
-        name += 2;
-        if( name[0] == '-' )
-            name++;
-        value = atobool(value) ? "false" : "true";
-    }
-    name_was_bool = 0;
-
-#define OPT(STR) else if( !strcmp( name, STR ) )
-#define OPT2(STR0, STR1) else if( !strcmp( name, STR0 ) || !strcmp( name, STR1 ) )
-    if( 0 );
-    OPT("asm")
-    {
-        p->cpu = isdigit(value[0]) ? atoi(value) :
-                 !strcasecmp(value, "auto") || atobool(value) ? x264_cpu_detect() : 0;
-        if( b_error )
-        {
-            char *buf = strdup( value );
-            if( buf )
-            {
-                char *tok, UNUSED *saveptr=NULL, *init;
-                b_error = 0;
-                p->cpu = 0;
-                for( init=buf; (tok=strtok_r(init, ",", &saveptr)); init=NULL )
-                {
-                    int i = 0;
-                    while( x264_cpu_names[i].flags && strcasecmp(tok, x264_cpu_names[i].name) )
-                        i++;
-                    p->cpu |= x264_cpu_names[i].flags;
-                    if( !x264_cpu_names[i].flags )
-                        b_error = 1;
-                }
-                free( buf );
-                if( (p->cpu&X264_CPU_SSSE3) && !(p->cpu&X264_CPU_SSE2_IS_SLOW) )
-                    p->cpu |= X264_CPU_SSE2_IS_FAST;
-            }
-        }
-    }
-    OPT("threads")
-    {
-        if( !strcasecmp(value, "auto") )
-            p->i_threads = X264_THREADS_AUTO;
-        else
-            p->i_threads = atoi(value);
-    }
-    OPT("lookahead-threads")
-    {
-        if( !strcasecmp(value, "auto") )
-            p->i_lookahead_threads = X264_THREADS_AUTO;
-        else
-            p->i_lookahead_threads = atoi(value);
-    }
-    OPT("sliced-threads")
-        p->b_sliced_threads = atobool(value);
-    OPT("sync-lookahead")
-    {
-        if( !strcasecmp(value, "auto") )
-            p->i_sync_lookahead = X264_SYNC_LOOKAHEAD_AUTO;
-        else
-            p->i_sync_lookahead = atoi(value);
-    }
-    OPT2("deterministic", "n-deterministic")
-        p->b_deterministic = atobool(value);
-    OPT("cpu-independent")
-        p->b_cpu_independent = atobool(value);
-    OPT2("level", "level-idc")
-    {
-        if( !strcmp(value, "1b") )
-            p->i_level_idc = 9;
-        else if( atof(value) < 7 )
-            p->i_level_idc = (int)(10*atof(value)+.5);
-        else
-            p->i_level_idc = atoi(value);
-    }
-    OPT("bluray-compat")
-        p->b_bluray_compat = atobool(value);
-    OPT("avcintra-class")
-        p->i_avcintra_class = atoi(value);
-    OPT("sar")
-    {
-        b_error = ( 2 != sscanf( value, "%d:%d", &p->vui.i_sar_width, &p->vui.i_sar_height ) &&
-                    2 != sscanf( value, "%d/%d", &p->vui.i_sar_width, &p->vui.i_sar_height ) );
-    }
-    OPT("overscan")
-        b_error |= parse_enum( value, x264_overscan_names, &p->vui.i_overscan );
-    OPT("videoformat")
-        b_error |= parse_enum( value, x264_vidformat_names, &p->vui.i_vidformat );
-    OPT("fullrange")
-        b_error |= parse_enum( value, x264_fullrange_names, &p->vui.b_fullrange );
-    OPT("colorprim")
-        b_error |= parse_enum( value, x264_colorprim_names, &p->vui.i_colorprim );
-    OPT("transfer")
-        b_error |= parse_enum( value, x264_transfer_names, &p->vui.i_transfer );
-    OPT("colormatrix")
-        b_error |= parse_enum( value, x264_colmatrix_names, &p->vui.i_colmatrix );
-    OPT("chromaloc")
-    {
-        p->vui.i_chroma_loc = atoi(value);
-        b_error = ( p->vui.i_chroma_loc < 0 || p->vui.i_chroma_loc > 5 );
-    }
-    OPT("fps")
-    {
-        if( sscanf( value, "%u/%u", &p->i_fps_num, &p->i_fps_den ) != 2 )
-        {
-            double fps = atof(value);
-            if( fps > 0.0 && fps <= INT_MAX/1000.0 )
-            {
-                p->i_fps_num = (int)(fps * 1000.0 + .5);
-                p->i_fps_den = 1000;
-            }
-            else
-            {
-                p->i_fps_num = atoi(value);
-                p->i_fps_den = 1;
-            }
-        }
-    }
-    OPT2("ref", "frameref")
-        p->i_frame_reference = atoi(value);
-    OPT("dpb-size")
-        p->i_dpb_size = atoi(value);
-    OPT("keyint")
-    {
-        if( strstr( value, "infinite" ) )
-            p->i_keyint_max = X264_KEYINT_MAX_INFINITE;
-        else
-            p->i_keyint_max = atoi(value);
-    }
-    OPT2("min-keyint", "keyint-min")
-    {
-        p->i_keyint_min = atoi(value);
-        if( p->i_keyint_max < p->i_keyint_min )
-            p->i_keyint_max = p->i_keyint_min;
-    }
-    OPT("scenecut")
-    {
-        p->i_scenecut_threshold = atobool(value);
-        if( b_error || p->i_scenecut_threshold )
-        {
-            b_error = 0;
-            p->i_scenecut_threshold = atoi(value);
-        }
-    }
-    OPT("intra-refresh")
-        p->b_intra_refresh = atobool(value);
-    OPT("bframes")
-        p->i_bframe = atoi(value);
-    OPT("b-adapt")
-    {
-        p->i_bframe_adaptive = atobool(value);
-        if( b_error )
-        {
-            b_error = 0;
-            p->i_bframe_adaptive = atoi(value);
-        }
-    }
-    OPT("b-bias")
-        p->i_bframe_bias = atoi(value);
-    OPT("b-pyramid")
-    {
-        b_error |= parse_enum( value, x264_b_pyramid_names, &p->i_bframe_pyramid );
-        if( b_error )
-        {
-            b_error = 0;
-            p->i_bframe_pyramid = atoi(value);
-        }
-    }
-    OPT("open-gop")
-        p->b_open_gop = atobool(value);
-    OPT("nf")
-        p->b_deblocking_filter = !atobool(value);
-    OPT2("filter", "deblock")
-    {
-        if( 2 == sscanf( value, "%d:%d", &p->i_deblocking_filter_alphac0, &p->i_deblocking_filter_beta ) ||
-            2 == sscanf( value, "%d,%d", &p->i_deblocking_filter_alphac0, &p->i_deblocking_filter_beta ) )
-        {
-            p->b_deblocking_filter = 1;
-        }
-        else if( sscanf( value, "%d", &p->i_deblocking_filter_alphac0 ) )
-        {
-            p->b_deblocking_filter = 1;
-            p->i_deblocking_filter_beta = p->i_deblocking_filter_alphac0;
-        }
-        else
-            p->b_deblocking_filter = atobool(value);
-    }
-    OPT("slice-max-size")
-        p->i_slice_max_size = atoi(value);
-    OPT("slice-max-mbs")
-        p->i_slice_max_mbs = atoi(value);
-    OPT("slice-min-mbs")
-        p->i_slice_min_mbs = atoi(value);
-    OPT("slices")
-        p->i_slice_count = atoi(value);
-    OPT("slices-max")
-        p->i_slice_count_max = atoi(value);
-    OPT("cabac")
-        p->b_cabac = atobool(value);
-    OPT("cabac-idc")
-        p->i_cabac_init_idc = atoi(value);
-    OPT("interlaced")
-        p->b_interlaced = atobool(value);
-    OPT("tff")
-        p->b_interlaced = p->b_tff = atobool(value);
-    OPT("bff")
-    {
-        p->b_interlaced = atobool(value);
-        p->b_tff = !p->b_interlaced;
-    }
-    OPT("constrained-intra")
-        p->b_constrained_intra = atobool(value);
-    OPT("cqm")
-    {
-        if( strstr( value, "flat" ) )
-            p->i_cqm_preset = X264_CQM_FLAT;
-        else if( strstr( value, "jvt" ) )
-            p->i_cqm_preset = X264_CQM_JVT;
-        else
-            p->psz_cqm_file = strdup(value);
-    }
-    OPT("cqmfile")
-        p->psz_cqm_file = strdup(value);
-    OPT("cqm4")
-    {
-        p->i_cqm_preset = X264_CQM_CUSTOM;
-        b_error |= parse_cqm( value, p->cqm_4iy, 16 );
-        b_error |= parse_cqm( value, p->cqm_4py, 16 );
-        b_error |= parse_cqm( value, p->cqm_4ic, 16 );
-        b_error |= parse_cqm( value, p->cqm_4pc, 16 );
-    }
-    OPT("cqm8")
-    {
-        p->i_cqm_preset = X264_CQM_CUSTOM;
-        b_error |= parse_cqm( value, p->cqm_8iy, 64 );
-        b_error |= parse_cqm( value, p->cqm_8py, 64 );
-        b_error |= parse_cqm( value, p->cqm_8ic, 64 );
-        b_error |= parse_cqm( value, p->cqm_8pc, 64 );
-    }
-    OPT("cqm4i")
-    {
-        p->i_cqm_preset = X264_CQM_CUSTOM;
-        b_error |= parse_cqm( value, p->cqm_4iy, 16 );
-        b_error |= parse_cqm( value, p->cqm_4ic, 16 );
-    }
-    OPT("cqm4p")
-    {
-        p->i_cqm_preset = X264_CQM_CUSTOM;
-        b_error |= parse_cqm( value, p->cqm_4py, 16 );
-        b_error |= parse_cqm( value, p->cqm_4pc, 16 );
-    }
-    OPT("cqm4iy")
-    {
-        p->i_cqm_preset = X264_CQM_CUSTOM;
-        b_error |= parse_cqm( value, p->cqm_4iy, 16 );
-    }
-    OPT("cqm4ic")
-    {
-        p->i_cqm_preset = X264_CQM_CUSTOM;
-        b_error |= parse_cqm( value, p->cqm_4ic, 16 );
-    }
-    OPT("cqm4py")
-    {
-        p->i_cqm_preset = X264_CQM_CUSTOM;
-        b_error |= parse_cqm( value, p->cqm_4py, 16 );
-    }
-    OPT("cqm4pc")
-    {
-        p->i_cqm_preset = X264_CQM_CUSTOM;
-        b_error |= parse_cqm( value, p->cqm_4pc, 16 );
-    }
-    OPT("cqm8i")
-    {
-        p->i_cqm_preset = X264_CQM_CUSTOM;
-        b_error |= parse_cqm( value, p->cqm_8iy, 64 );
-        b_error |= parse_cqm( value, p->cqm_8ic, 64 );
-    }
-    OPT("cqm8p")
-    {
-        p->i_cqm_preset = X264_CQM_CUSTOM;
-        b_error |= parse_cqm( value, p->cqm_8py, 64 );
-        b_error |= parse_cqm( value, p->cqm_8pc, 64 );
-    }
-    OPT("log")
-        p->i_log_level = atoi(value);
-    OPT("dump-yuv")
-        p->psz_dump_yuv = strdup(value);
-    OPT2("analyse", "partitions")
-    {
-        p->analyse.inter = 0;
-        if( strstr( value, "none" ) )  p->analyse.inter =  0;
-        if( strstr( value, "all" ) )   p->analyse.inter = ~0;
-
-        if( strstr( value, "i4x4" ) )  p->analyse.inter |= X264_ANALYSE_I4x4;
-        if( strstr( value, "i8x8" ) )  p->analyse.inter |= X264_ANALYSE_I8x8;
-        if( strstr( value, "p8x8" ) )  p->analyse.inter |= X264_ANALYSE_PSUB16x16;
-        if( strstr( value, "p4x4" ) )  p->analyse.inter |= X264_ANALYSE_PSUB8x8;
-        if( strstr( value, "b8x8" ) )  p->analyse.inter |= X264_ANALYSE_BSUB16x16;
-    }
-    OPT("8x8dct")
-        p->analyse.b_transform_8x8 = atobool(value);
-    OPT2("weightb", "weight-b")
-        p->analyse.b_weighted_bipred = atobool(value);
-    OPT("weightp")
-        p->analyse.i_weighted_pred = atoi(value);
-    OPT2("direct", "direct-pred")
-        b_error |= parse_enum( value, x264_direct_pred_names, &p->analyse.i_direct_mv_pred );
-    OPT("chroma-qp-offset")
-        p->analyse.i_chroma_qp_offset = atoi(value);
-    OPT("me")
-        b_error |= parse_enum( value, x264_motion_est_names, &p->analyse.i_me_method );
-    OPT2("merange", "me-range")
-        p->analyse.i_me_range = atoi(value);
-    OPT2("mvrange", "mv-range")
-        p->analyse.i_mv_range = atoi(value);
-    OPT2("mvrange-thread", "mv-range-thread")
-        p->analyse.i_mv_range_thread = atoi(value);
-    OPT2("subme", "subq")
-        p->analyse.i_subpel_refine = atoi(value);
-    OPT("psy-rd")
-    {
-        if( 2 == sscanf( value, "%f:%f", &p->analyse.f_psy_rd, &p->analyse.f_psy_trellis ) ||
-            2 == sscanf( value, "%f,%f", &p->analyse.f_psy_rd, &p->analyse.f_psy_trellis ) ||
-            2 == sscanf( value, "%f|%f", &p->analyse.f_psy_rd, &p->analyse.f_psy_trellis ))
-        { }
-        else if( sscanf( value, "%f", &p->analyse.f_psy_rd ) )
-        {
-            p->analyse.f_psy_trellis = 0;
-        }
-        else
-        {
-            p->analyse.f_psy_rd = 0;
-            p->analyse.f_psy_trellis = 0;
-        }
-    }
-    OPT("psy")
-        p->analyse.b_psy = atobool(value);
-    OPT("chroma-me")
-        p->analyse.b_chroma_me = atobool(value);
-    OPT("mixed-refs")
-        p->analyse.b_mixed_references = atobool(value);
-    OPT("trellis")
-        p->analyse.i_trellis = atoi(value);
-    OPT("fast-pskip")
-        p->analyse.b_fast_pskip = atobool(value);
-    OPT("dct-decimate")
-        p->analyse.b_dct_decimate = atobool(value);
-    OPT("deadzone-inter")
-        p->analyse.i_luma_deadzone[0] = atoi(value);
-    OPT("deadzone-intra")
-        p->analyse.i_luma_deadzone[1] = atoi(value);
-    OPT("nr")
-        p->analyse.i_noise_reduction = atoi(value);
-    OPT("bitrate")
-    {
-        p->rc.i_bitrate = atoi(value);
-        p->rc.i_rc_method = X264_RC_ABR;
-    }
-    OPT2("qp", "qp_constant")
-    {
-        p->rc.i_qp_constant = atoi(value);
-        p->rc.i_rc_method = X264_RC_CQP;
-    }
-    OPT("crf")
-    {
-        p->rc.f_rf_constant = atof(value);
-        p->rc.i_rc_method = X264_RC_CRF;
-    }
-    OPT("crf-max")
-        p->rc.f_rf_constant_max = atof(value);
-    OPT("rc-lookahead")
-        p->rc.i_lookahead = atoi(value);
-    OPT2("qpmin", "qp-min")
-        p->rc.i_qp_min = atoi(value);
-    OPT2("qpmax", "qp-max")
-        p->rc.i_qp_max = atoi(value);
-    OPT2("qpstep", "qp-step")
-        p->rc.i_qp_step = atoi(value);
-    OPT("ratetol")
-        p->rc.f_rate_tolerance = !strncmp("inf", value, 3) ? 1e9 : atof(value);
-    OPT("vbv-maxrate")
-        p->rc.i_vbv_max_bitrate = atoi(value);
-    OPT("vbv-bufsize")
-        p->rc.i_vbv_buffer_size = atoi(value);
-    OPT("vbv-init")
-        p->rc.f_vbv_buffer_init = atof(value);
-    OPT2("ipratio", "ip-factor")
-        p->rc.f_ip_factor = atof(value);
-    OPT2("pbratio", "pb-factor")
-        p->rc.f_pb_factor = atof(value);
-    OPT("aq-mode")
-        p->rc.i_aq_mode = atoi(value);
-    OPT("aq-strength")
-        p->rc.f_aq_strength = atof(value);
-    OPT("pass")
-    {
-        int pass = x264_clip3( atoi(value), 0, 3 );
-        p->rc.b_stat_write = pass & 1;
-        p->rc.b_stat_read = pass & 2;
-    }
-    OPT("stats")
-    {
-        p->rc.psz_stat_in = strdup(value);
-        p->rc.psz_stat_out = strdup(value);
-    }
-    OPT("qcomp")
-        p->rc.f_qcompress = atof(value);
-    OPT("mbtree")
-        p->rc.b_mb_tree = atobool(value);
-    OPT("qblur")
-        p->rc.f_qblur = atof(value);
-    OPT2("cplxblur", "cplx-blur")
-        p->rc.f_complexity_blur = atof(value);
-    OPT("zones")
-        p->rc.psz_zones = strdup(value);
-    OPT("crop-rect")
-        b_error |= sscanf( value, "%u,%u,%u,%u", &p->crop_rect.i_left, &p->crop_rect.i_top,
-                                                 &p->crop_rect.i_right, &p->crop_rect.i_bottom ) != 4;
-    OPT("psnr")
-        p->analyse.b_psnr = atobool(value);
-    OPT("ssim")
-        p->analyse.b_ssim = atobool(value);
-    OPT("aud")
-        p->b_aud = atobool(value);
-    OPT("sps-id")
-        p->i_sps_id = atoi(value);
-    OPT("global-header")
-        p->b_repeat_headers = !atobool(value);
-    OPT("repeat-headers")
-        p->b_repeat_headers = atobool(value);
-    OPT("annexb")
-        p->b_annexb = atobool(value);
-    OPT("force-cfr")
-        p->b_vfr_input = !atobool(value);
-    OPT("nal-hrd")
-        b_error |= parse_enum( value, x264_nal_hrd_names, &p->i_nal_hrd );
-    OPT("filler")
-        p->rc.b_filler = atobool(value);
-    OPT("pic-struct")
-        p->b_pic_struct = atobool(value);
-    OPT("fake-interlaced")
-        p->b_fake_interlaced = atobool(value);
-    OPT("frame-packing")
-        p->i_frame_packing = atoi(value);
-    OPT("stitchable")
-        p->b_stitchable = atobool(value);
-    OPT("opencl")
-        p->b_opencl = atobool( value );
-    OPT("opencl-clbin")
-        p->psz_clbin_file = strdup( value );
-    OPT("opencl-device")
-        p->i_opencl_device = atoi( value );
-    else
-    {
-        b_error = 1;
-        errortype = X264_PARAM_BAD_NAME;
-    }
-#undef OPT
-#undef OPT2
-#undef atobool
-#undef atoi
-#undef atof
-
-    if( name_buf )
-        free( name_buf );
-
-    b_error |= value_was_null && !name_was_bool;
-    return b_error ? errortype : 0;
-}
-
 /****************************************************************************
  * x264_log:
  ****************************************************************************/
@@ -1079,368 +36,9 @@ void x264_log( x264_t *h, int i_level, const char *psz_fmt, ... )
         va_list arg;
         va_start( arg, psz_fmt );
         if( !h )
-            log_default( NULL, i_level, psz_fmt, arg );
+            x264_log_default( NULL, i_level, psz_fmt, arg );
         else
             h->param.pf_log( h->param.p_log_private, i_level, psz_fmt, arg );
         va_end( arg );
     }
 }
-
-static void log_default( void *p_unused, int i_level, const char *psz_fmt, va_list arg )
-{
-    char *psz_prefix;
-    switch( i_level )
-    {
-        case X264_LOG_ERROR:
-            psz_prefix = "error";
-            break;
-        case X264_LOG_WARNING:
-            psz_prefix = "warning";
-            break;
-        case X264_LOG_INFO:
-            psz_prefix = "info";
-            break;
-        case X264_LOG_DEBUG:
-            psz_prefix = "debug";
-            break;
-        default:
-            psz_prefix = "unknown";
-            break;
-    }
-    fprintf( stderr, "x264 [%s]: ", psz_prefix );
-    x264_vfprintf( stderr, psz_fmt, arg );
-}
-
-/****************************************************************************
- * x264_picture_init:
- ****************************************************************************/
-void x264_picture_init( x264_picture_t *pic )
-{
-    memset( pic, 0, sizeof( x264_picture_t ) );
-    pic->i_type = X264_TYPE_AUTO;
-    pic->i_qpplus1 = X264_QP_AUTO;
-    pic->i_pic_struct = PIC_STRUCT_AUTO;
-}
-
-/****************************************************************************
- * x264_picture_alloc:
- ****************************************************************************/
-int x264_picture_alloc( x264_picture_t *pic, int i_csp, int i_width, int i_height )
-{
-    typedef struct
-    {
-        int planes;
-        int width_fix8[3];
-        int height_fix8[3];
-    } x264_csp_tab_t;
-
-    static const x264_csp_tab_t csp_tab[] =
-    {
-        [X264_CSP_I420] = { 3, { 256*1, 256/2, 256/2 }, { 256*1, 256/2, 256/2 } },
-        [X264_CSP_YV12] = { 3, { 256*1, 256/2, 256/2 }, { 256*1, 256/2, 256/2 } },
-        [X264_CSP_NV12] = { 2, { 256*1, 256*1 },        { 256*1, 256/2 },       },
-        [X264_CSP_NV21] = { 2, { 256*1, 256*1 },        { 256*1, 256/2 },       },
-        [X264_CSP_I422] = { 3, { 256*1, 256/2, 256/2 }, { 256*1, 256*1, 256*1 } },
-        [X264_CSP_YV16] = { 3, { 256*1, 256/2, 256/2 }, { 256*1, 256*1, 256*1 } },
-        [X264_CSP_NV16] = { 2, { 256*1, 256*1 },        { 256*1, 256*1 },       },
-        [X264_CSP_YUYV] = { 1, { 256*2 },               { 256*1 },              },
-        [X264_CSP_UYVY] = { 1, { 256*2 },               { 256*1 },              },
-        [X264_CSP_I444] = { 3, { 256*1, 256*1, 256*1 }, { 256*1, 256*1, 256*1 } },
-        [X264_CSP_YV24] = { 3, { 256*1, 256*1, 256*1 }, { 256*1, 256*1, 256*1 } },
-        [X264_CSP_BGR]  = { 1, { 256*3 },               { 256*1 },              },
-        [X264_CSP_BGRA] = { 1, { 256*4 },               { 256*1 },              },
-        [X264_CSP_RGB]  = { 1, { 256*3 },               { 256*1 },              },
-    };
-
-    int csp = i_csp & X264_CSP_MASK;
-    if( csp <= X264_CSP_NONE || csp >= X264_CSP_MAX || csp == X264_CSP_V210 )
-        return -1;
-    x264_picture_init( pic );
-    pic->img.i_csp = i_csp;
-    pic->img.i_plane = csp_tab[csp].planes;
-    int depth_factor = i_csp & X264_CSP_HIGH_DEPTH ? 2 : 1;
-    int plane_offset[3] = {0};
-    int frame_size = 0;
-    for( int i = 0; i < pic->img.i_plane; i++ )
-    {
-        int stride = (((int64_t)i_width * csp_tab[csp].width_fix8[i]) >> 8) * depth_factor;
-        int plane_size = (((int64_t)i_height * csp_tab[csp].height_fix8[i]) >> 8) * stride;
-        pic->img.i_stride[i] = stride;
-        plane_offset[i] = frame_size;
-        frame_size += plane_size;
-    }
-    pic->img.plane[0] = x264_malloc( frame_size );
-    if( !pic->img.plane[0] )
-        return -1;
-    for( int i = 1; i < pic->img.i_plane; i++ )
-        pic->img.plane[i] = pic->img.plane[0] + plane_offset[i];
-    return 0;
-}
-
-/****************************************************************************
- * x264_picture_clean:
- ****************************************************************************/
-void x264_picture_clean( x264_picture_t *pic )
-{
-    x264_free( pic->img.plane[0] );
-
-    /* just to be safe */
-    memset( pic, 0, sizeof( x264_picture_t ) );
-}
-
-/****************************************************************************
- * x264_malloc:
- ****************************************************************************/
-void *x264_malloc( int i_size )
-{
-    uint8_t *align_buf = NULL;
-#if HAVE_MALLOC_H
-#if HAVE_THP
-#define HUGE_PAGE_SIZE 2*1024*1024
-#define HUGE_PAGE_THRESHOLD HUGE_PAGE_SIZE*7/8 /* FIXME: Is this optimal? */
-    /* Attempt to allocate huge pages to reduce TLB misses. */
-    if( i_size >= HUGE_PAGE_THRESHOLD )
-    {
-        align_buf = memalign( HUGE_PAGE_SIZE, i_size );
-        if( align_buf )
-        {
-            /* Round up to the next huge page boundary if we are close enough. */
-            size_t madv_size = (i_size + HUGE_PAGE_SIZE - HUGE_PAGE_THRESHOLD) & ~(HUGE_PAGE_SIZE-1);
-            madvise( align_buf, madv_size, MADV_HUGEPAGE );
-        }
-    }
-    else
-#undef HUGE_PAGE_SIZE
-#undef HUGE_PAGE_THRESHOLD
-#endif
-        align_buf = memalign( NATIVE_ALIGN, i_size );
-#else
-    uint8_t *buf = malloc( i_size + (NATIVE_ALIGN-1) + sizeof(void **) );
-    if( buf )
-    {
-        align_buf = buf + (NATIVE_ALIGN-1) + sizeof(void **);
-        align_buf -= (intptr_t) align_buf & (NATIVE_ALIGN-1);
-        *( (void **) ( align_buf - sizeof(void **) ) ) = buf;
-    }
-#endif
-    if( !align_buf )
-        x264_log( NULL, X264_LOG_ERROR, "malloc of size %d failed\n", i_size );
-    return align_buf;
-}
-
-/****************************************************************************
- * x264_free:
- ****************************************************************************/
-void x264_free( void *p )
-{
-    if( p )
-    {
-#if HAVE_MALLOC_H
-        free( p );
-#else
-        free( *( ( ( void **) p ) - 1 ) );
-#endif
-    }
-}
-
-/****************************************************************************
- * x264_reduce_fraction:
- ****************************************************************************/
-#define REDUCE_FRACTION( name, type )\
-void name( type *n, type *d )\
-{                   \
-    type a = *n;    \
-    type b = *d;    \
-    type c;         \
-    if( !a || !b )  \
-        return;     \
-    c = a % b;      \
-    while( c )      \
-    {               \
-        a = b;      \
-        b = c;      \
-        c = a % b;  \
-    }               \
-    *n /= b;        \
-    *d /= b;        \
-}
-
-REDUCE_FRACTION( x264_reduce_fraction  , uint32_t )
-REDUCE_FRACTION( x264_reduce_fraction64, uint64_t )
-
-/****************************************************************************
- * x264_slurp_file:
- ****************************************************************************/
-char *x264_slurp_file( const char *filename )
-{
-    int b_error = 0;
-    int64_t i_size;
-    char *buf;
-    FILE *fh = x264_fopen( filename, "rb" );
-    if( !fh )
-        return NULL;
-
-    b_error |= fseek( fh, 0, SEEK_END ) < 0;
-    b_error |= ( i_size = ftell( fh ) ) <= 0;
-    if( WORD_SIZE == 4 )
-        b_error |= i_size > INT32_MAX;
-    b_error |= fseek( fh, 0, SEEK_SET ) < 0;
-    if( b_error )
-        goto error;
-
-    buf = x264_malloc( i_size+2 );
-    if( !buf )
-        goto error;
-
-    b_error |= fread( buf, 1, i_size, fh ) != i_size;
-    fclose( fh );
-    if( b_error )
-    {
-        x264_free( buf );
-        return NULL;
-    }
-
-    if( buf[i_size-1] != '\n' )
-        buf[i_size++] = '\n';
-    buf[i_size] = '\0';
-
-    return buf;
-error:
-    fclose( fh );
-    return NULL;
-}
-
-/****************************************************************************
- * x264_param2string:
- ****************************************************************************/
-char *x264_param2string( x264_param_t *p, int b_res )
-{
-    int len = 1000;
-    char *buf, *s;
-    if( p->rc.psz_zones )
-        len += strlen(p->rc.psz_zones);
-    buf = s = x264_malloc( len );
-    if( !buf )
-        return NULL;
-
-    if( b_res )
-    {
-        s += sprintf( s, "%dx%d ", p->i_width, p->i_height );
-        s += sprintf( s, "fps=%u/%u ", p->i_fps_num, p->i_fps_den );
-        s += sprintf( s, "timebase=%u/%u ", p->i_timebase_num, p->i_timebase_den );
-        s += sprintf( s, "bitdepth=%d ", BIT_DEPTH );
-    }
-
-    if( p->b_opencl )
-        s += sprintf( s, "opencl=%d ", p->b_opencl );
-    s += sprintf( s, "cabac=%d", p->b_cabac );
-    s += sprintf( s, " ref=%d", p->i_frame_reference );
-    s += sprintf( s, " deblock=%d:%d:%d", p->b_deblocking_filter,
-                  p->i_deblocking_filter_alphac0, p->i_deblocking_filter_beta );
-    s += sprintf( s, " analyse=%#x:%#x", p->analyse.intra, p->analyse.inter );
-    s += sprintf( s, " me=%s", x264_motion_est_names[ p->analyse.i_me_method ] );
-    s += sprintf( s, " subme=%d", p->analyse.i_subpel_refine );
-    s += sprintf( s, " psy=%d", p->analyse.b_psy );
-    if( p->analyse.b_psy )
-        s += sprintf( s, " psy_rd=%.2f:%.2f", p->analyse.f_psy_rd, p->analyse.f_psy_trellis );
-    s += sprintf( s, " mixed_ref=%d", p->analyse.b_mixed_references );
-    s += sprintf( s, " me_range=%d", p->analyse.i_me_range );
-    s += sprintf( s, " chroma_me=%d", p->analyse.b_chroma_me );
-    s += sprintf( s, " trellis=%d", p->analyse.i_trellis );
-    s += sprintf( s, " 8x8dct=%d", p->analyse.b_transform_8x8 );
-    s += sprintf( s, " cqm=%d", p->i_cqm_preset );
-    s += sprintf( s, " deadzone=%d,%d", p->analyse.i_luma_deadzone[0], p->analyse.i_luma_deadzone[1] );
-    s += sprintf( s, " fast_pskip=%d", p->analyse.b_fast_pskip );
-    s += sprintf( s, " chroma_qp_offset=%d", p->analyse.i_chroma_qp_offset );
-    s += sprintf( s, " threads=%d", p->i_threads );
-    s += sprintf( s, " lookahead_threads=%d", p->i_lookahead_threads );
-    s += sprintf( s, " sliced_threads=%d", p->b_sliced_threads );
-    if( p->i_slice_count )
-        s += sprintf( s, " slices=%d", p->i_slice_count );
-    if( p->i_slice_count_max )
-        s += sprintf( s, " slices_max=%d", p->i_slice_count_max );
-    if( p->i_slice_max_size )
-        s += sprintf( s, " slice_max_size=%d", p->i_slice_max_size );
-    if( p->i_slice_max_mbs )
-        s += sprintf( s, " slice_max_mbs=%d", p->i_slice_max_mbs );
-    if( p->i_slice_min_mbs )
-        s += sprintf( s, " slice_min_mbs=%d", p->i_slice_min_mbs );
-    s += sprintf( s, " nr=%d", p->analyse.i_noise_reduction );
-    s += sprintf( s, " decimate=%d", p->analyse.b_dct_decimate );
-    s += sprintf( s, " interlaced=%s", p->b_interlaced ? p->b_tff ? "tff" : "bff" : p->b_fake_interlaced ? "fake" : "0" );
-    s += sprintf( s, " bluray_compat=%d", p->b_bluray_compat );
-    if( p->b_stitchable )
-        s += sprintf( s, " stitchable=%d", p->b_stitchable );
-
-    s += sprintf( s, " constrained_intra=%d", p->b_constrained_intra );
-
-    s += sprintf( s, " bframes=%d", p->i_bframe );
-    if( p->i_bframe )
-    {
-        s += sprintf( s, " b_pyramid=%d b_adapt=%d b_bias=%d direct=%d weightb=%d open_gop=%d",
-                      p->i_bframe_pyramid, p->i_bframe_adaptive, p->i_bframe_bias,
-                      p->analyse.i_direct_mv_pred, p->analyse.b_weighted_bipred, p->b_open_gop );
-    }
-    s += sprintf( s, " weightp=%d", p->analyse.i_weighted_pred > 0 ? p->analyse.i_weighted_pred : 0 );
-
-    if( p->i_keyint_max == X264_KEYINT_MAX_INFINITE )
-        s += sprintf( s, " keyint=infinite" );
-    else
-        s += sprintf( s, " keyint=%d", p->i_keyint_max );
-    s += sprintf( s, " keyint_min=%d scenecut=%d intra_refresh=%d",
-                  p->i_keyint_min, p->i_scenecut_threshold, p->b_intra_refresh );
-
-    if( p->rc.b_mb_tree || p->rc.i_vbv_buffer_size )
-        s += sprintf( s, " rc_lookahead=%d", p->rc.i_lookahead );
-
-    s += sprintf( s, " rc=%s mbtree=%d", p->rc.i_rc_method == X264_RC_ABR ?
-                               ( p->rc.b_stat_read ? "2pass" : p->rc.i_vbv_max_bitrate == p->rc.i_bitrate ? "cbr" : "abr" )
-                               : p->rc.i_rc_method == X264_RC_CRF ? "crf" : "cqp", p->rc.b_mb_tree );
-    if( p->rc.i_rc_method == X264_RC_ABR || p->rc.i_rc_method == X264_RC_CRF )
-    {
-        if( p->rc.i_rc_method == X264_RC_CRF )
-            s += sprintf( s, " crf=%.1f", p->rc.f_rf_constant );
-        else
-            s += sprintf( s, " bitrate=%d ratetol=%.1f",
-                          p->rc.i_bitrate, p->rc.f_rate_tolerance );
-        s += sprintf( s, " qcomp=%.2f qpmin=%d qpmax=%d qpstep=%d",
-                      p->rc.f_qcompress, p->rc.i_qp_min, p->rc.i_qp_max, p->rc.i_qp_step );
-        if( p->rc.b_stat_read )
-            s += sprintf( s, " cplxblur=%.1f qblur=%.1f",
-                          p->rc.f_complexity_blur, p->rc.f_qblur );
-        if( p->rc.i_vbv_buffer_size )
-        {
-            s += sprintf( s, " vbv_maxrate=%d vbv_bufsize=%d",
-                          p->rc.i_vbv_max_bitrate, p->rc.i_vbv_buffer_size );
-            if( p->rc.i_rc_method == X264_RC_CRF )
-                s += sprintf( s, " crf_max=%.1f", p->rc.f_rf_constant_max );
-        }
-    }
-    else if( p->rc.i_rc_method == X264_RC_CQP )
-        s += sprintf( s, " qp=%d", p->rc.i_qp_constant );
-
-    if( p->rc.i_vbv_buffer_size )
-        s += sprintf( s, " nal_hrd=%s filler=%d", x264_nal_hrd_names[p->i_nal_hrd], p->rc.b_filler );
-    if( p->crop_rect.i_left | p->crop_rect.i_top | p->crop_rect.i_right | p->crop_rect.i_bottom )
-        s += sprintf( s, " crop_rect=%u,%u,%u,%u", p->crop_rect.i_left, p->crop_rect.i_top,
-                                                   p->crop_rect.i_right, p->crop_rect.i_bottom );
-    if( p->i_frame_packing >= 0 )
-        s += sprintf( s, " frame-packing=%d", p->i_frame_packing );
-
-    if( !(p->rc.i_rc_method == X264_RC_CQP && p->rc.i_qp_constant == 0) )
-    {
-        s += sprintf( s, " ip_ratio=%.2f", p->rc.f_ip_factor );
-        if( p->i_bframe && !p->rc.b_mb_tree )
-            s += sprintf( s, " pb_ratio=%.2f", p->rc.f_pb_factor );
-        s += sprintf( s, " aq=%d", p->rc.i_aq_mode );
-        if( p->rc.i_aq_mode )
-            s += sprintf( s, ":%.2f", p->rc.f_aq_strength );
-        if( p->rc.psz_zones )
-            s += sprintf( s, " zones=%s", p->rc.psz_zones );
-        else if( p->rc.i_zones )
-            s += sprintf( s, " zones" );
-    }
-
-    return buf;
-}
-
index 867b2073c0c7968d5a5410e1faf6b67273221b21..162cfb4de0b82a988dd1cd6a741db5d25a209f0e 100644 (file)
 #ifndef X264_COMMON_H
 #define X264_COMMON_H
 
+#include "base.h"
+
+/* Macros for templating function calls according to bit depth */
+#define x264_template(w) x264_glue3(x264, BIT_DEPTH, w)
+
+/****************************************************************************
+ * API Templates
+ ****************************************************************************/
+#define x264_nal_encode x264_template(nal_encode)
+#define x264_encoder_reconfig x264_template(encoder_reconfig)
+#define x264_encoder_parameters x264_template(encoder_parameters)
+#define x264_encoder_headers x264_template(encoder_headers)
+#define x264_encoder_encode x264_template(encoder_encode)
+#define x264_encoder_close x264_template(encoder_close)
+#define x264_encoder_delayed_frames x264_template(encoder_delayed_frames)
+#define x264_encoder_maximum_delayed_frames x264_template(encoder_maximum_delayed_frames)
+#define x264_encoder_intra_refresh x264_template(encoder_intra_refresh)
+#define x264_encoder_invalidate_reference x264_template(encoder_invalidate_reference)
+
+/* This undef allows to rename the external symbol and force link failure in case
+ * of incompatible libraries. Then the define enables templating as above. */
+#undef x264_encoder_open
+#define x264_encoder_open x264_template(encoder_open)
+
 /****************************************************************************
  * Macros
  ****************************************************************************/
-#define X264_MIN(a,b) ( (a)<(b) ? (a) : (b) )
-#define X264_MAX(a,b) ( (a)>(b) ? (a) : (b) )
-#define X264_MIN3(a,b,c) X264_MIN((a),X264_MIN((b),(c)))
-#define X264_MAX3(a,b,c) X264_MAX((a),X264_MAX((b),(c)))
-#define X264_MIN4(a,b,c,d) X264_MIN((a),X264_MIN3((b),(c),(d)))
-#define X264_MAX4(a,b,c,d) X264_MAX((a),X264_MAX3((b),(c),(d)))
-#define XCHG(type,a,b) do { type t = a; a = b; b = t; } while( 0 )
-#define IS_DISPOSABLE(type) ( type == X264_TYPE_B )
-#define FIX8(f) ((int)(f*(1<<8)+.5))
-#define ALIGN(x,a) (((x)+((a)-1))&~((a)-1))
-#define ARRAY_ELEMS(a) ((sizeof(a))/(sizeof(a[0])))
-
-#define CHECKED_MALLOC( var, size )\
-do {\
-    var = x264_malloc( size );\
-    if( !var )\
-        goto fail;\
-} while( 0 )
-#define CHECKED_MALLOCZERO( var, size )\
-do {\
-    CHECKED_MALLOC( var, size );\
-    memset( var, 0, size );\
-} while( 0 )
-
-/* Macros for merging multiple allocations into a single large malloc, for improved
- * use with huge pages. */
-
-/* Needs to be enough to contain any set of buffers that use combined allocations */
-#define PREALLOC_BUF_SIZE 1024
-
-#define PREALLOC_INIT\
-    int    prealloc_idx = 0;\
-    size_t prealloc_size = 0;\
-    uint8_t **preallocs[PREALLOC_BUF_SIZE];
-
-#define PREALLOC( var, size )\
-do {\
-    var = (void*)prealloc_size;\
-    preallocs[prealloc_idx++] = (uint8_t**)&var;\
-    prealloc_size += ALIGN(size, NATIVE_ALIGN);\
-} while( 0 )
-
-#define PREALLOC_END( ptr )\
-do {\
-    CHECKED_MALLOC( ptr, prealloc_size );\
-    while( prealloc_idx-- )\
-        *preallocs[prealloc_idx] += (intptr_t)ptr;\
-} while( 0 )
-
-#define ARRAY_SIZE(array)  (sizeof(array)/sizeof(array[0]))
-
-#define X264_BFRAME_MAX 16
-#define X264_REF_MAX 16
-#define X264_THREAD_MAX 128
-#define X264_LOOKAHEAD_THREAD_MAX 16
 #define X264_PCM_COST (FRAME_SIZE(256*BIT_DEPTH)+16)
-#define X264_LOOKAHEAD_MAX 250
 #define QP_BD_OFFSET (6*(BIT_DEPTH-8))
 #define QP_MAX_SPEC (51+QP_BD_OFFSET)
 #define QP_MAX (QP_MAX_SPEC+18)
-#define QP_MAX_MAX (51+2*6+18)
 #define PIXEL_MAX ((1 << BIT_DEPTH)-1)
 // arbitrary, but low because SATD scores are 1/4 normal
 #define X264_LOOKAHEAD_QP (12+QP_BD_OFFSET)
 #define SPEC_QP(x) X264_MIN((x), QP_MAX_SPEC)
 
-// number of pixels (per thread) in progress at any given time.
-// 16 for the macroblock in progress + 3 for deblocking + 3 for motion compensation filter + 2 for extra safety
-#define X264_THREAD_HEIGHT 24
-
-/* WEIGHTP_FAKE is set when mb_tree & psy are enabled, but normal weightp is disabled
- * (such as in baseline). It checks for fades in lookahead and adjusts qp accordingly
- * to increase quality. Defined as (-1) so that if(i_weighted_pred > 0) is true only when
- * real weights are being used. */
-
-#define X264_WEIGHTP_FAKE (-1)
-
 #define NALU_OVERHEAD 5 // startcode + NAL type costs 5 bytes per frame
 #define FILLER_OVERHEAD (NALU_OVERHEAD+1)
 #define SEI_OVERHEAD (NALU_OVERHEAD - (h->param.b_annexb && !h->param.i_avcintra_class && (h->out.i_nal-1)))
 
-/****************************************************************************
- * Includes
- ****************************************************************************/
-#include "osdep.h"
-#include <stdarg.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <limits.h>
-
 #if HAVE_INTERLACED
 #   define MB_INTERLACED h->mb.b_interlaced
 #   define SLICE_MBAFF h->sh.b_mbaff
@@ -145,25 +90,6 @@ do {\
 #define FRAME_SIZE(s) ((s)+2*CHROMA_SIZE(s))
 #define CHROMA444 (CHROMA_FORMAT == CHROMA_444)
 
-/* Unions for type-punning.
- * Mn: load or store n bits, aligned, native-endian
- * CPn: copy n bits, aligned, native-endian
- * we don't use memcpy for CPn because memcpy's args aren't assumed to be aligned */
-typedef union { uint16_t i; uint8_t  c[2]; } MAY_ALIAS x264_union16_t;
-typedef union { uint32_t i; uint16_t b[2]; uint8_t  c[4]; } MAY_ALIAS x264_union32_t;
-typedef union { uint64_t i; uint32_t a[2]; uint16_t b[4]; uint8_t c[8]; } MAY_ALIAS x264_union64_t;
-typedef struct { uint64_t i[2]; } x264_uint128_t;
-typedef union { x264_uint128_t i; uint64_t a[2]; uint32_t b[4]; uint16_t c[8]; uint8_t d[16]; } MAY_ALIAS x264_union128_t;
-#define M16(src) (((x264_union16_t*)(src))->i)
-#define M32(src) (((x264_union32_t*)(src))->i)
-#define M64(src) (((x264_union64_t*)(src))->i)
-#define M128(src) (((x264_union128_t*)(src))->i)
-#define M128_ZERO ((x264_uint128_t){{0,0}})
-#define CP16(dst,src) M16(dst) = M16(src)
-#define CP32(dst,src) M32(dst) = M32(src)
-#define CP64(dst,src) M64(dst) = M64(src)
-#define CP128(dst,src) M128(dst) = M128(src)
-
 #if HIGH_BIT_DEPTH
     typedef uint16_t pixel;
     typedef uint64_t pixel4;
@@ -182,55 +108,11 @@ typedef union { x264_uint128_t i; uint64_t a[2]; uint32_t b[4]; uint16_t c[8]; u
 #   define MPIXEL_X4(src) M32(src)
 #endif
 
-#define BIT_DEPTH X264_BIT_DEPTH
-
 #define CPPIXEL_X4(dst,src) MPIXEL_X4(dst) = MPIXEL_X4(src)
 
-#define X264_SCAN8_LUMA_SIZE (5*8)
-#define X264_SCAN8_SIZE (X264_SCAN8_LUMA_SIZE*3)
-#define X264_SCAN8_0 (4+1*8)
-
-/* Scan8 organization:
- *    0 1 2 3 4 5 6 7
- * 0  DY    y y y y y
- * 1        y Y Y Y Y
- * 2        y Y Y Y Y
- * 3        y Y Y Y Y
- * 4        y Y Y Y Y
- * 5  DU    u u u u u
- * 6        u U U U U
- * 7        u U U U U
- * 8        u U U U U
- * 9        u U U U U
- * 10 DV    v v v v v
- * 11       v V V V V
- * 12       v V V V V
- * 13       v V V V V
- * 14       v V V V V
- * DY/DU/DV are for luma/chroma DC.
- */
-
-#define LUMA_DC   48
-#define CHROMA_DC 49
-
-static const uint8_t x264_scan8[16*3 + 3] =
-{
-    4+ 1*8, 5+ 1*8, 4+ 2*8, 5+ 2*8,
-    6+ 1*8, 7+ 1*8, 6+ 2*8, 7+ 2*8,
-    4+ 3*8, 5+ 3*8, 4+ 4*8, 5+ 4*8,
-    6+ 3*8, 7+ 3*8, 6+ 4*8, 7+ 4*8,
-    4+ 6*8, 5+ 6*8, 4+ 7*8, 5+ 7*8,
-    6+ 6*8, 7+ 6*8, 6+ 7*8, 7+ 7*8,
-    4+ 8*8, 5+ 8*8, 4+ 9*8, 5+ 9*8,
-    6+ 8*8, 7+ 8*8, 6+ 9*8, 7+ 9*8,
-    4+11*8, 5+11*8, 4+12*8, 5+12*8,
-    6+11*8, 7+11*8, 6+12*8, 7+12*8,
-    4+13*8, 5+13*8, 4+14*8, 5+14*8,
-    6+13*8, 7+13*8, 6+14*8, 7+14*8,
-    0+ 0*8, 0+ 5*8, 0+10*8
-};
-
-#include "x264.h"
+/****************************************************************************
+ * Includes
+ ****************************************************************************/
 #if HAVE_OPENCL
 #include "opencl.h"
 #endif
@@ -243,30 +125,19 @@ static const uint8_t x264_scan8[16*3 + 3] =
 #include "frame.h"
 #include "dct.h"
 #include "quant.h"
-#include "cpu.h"
 #include "threadpool.h"
 
 /****************************************************************************
  * General functions
  ****************************************************************************/
-/* x264_malloc : will do or emulate a memalign
- * you have to use x264_free for buffers allocated with x264_malloc */
-void *x264_malloc( int );
-void  x264_free( void * );
-
-/* x264_slurp_file: malloc space for the whole file and read it */
-char *x264_slurp_file( const char *filename );
-
-/* x264_param2string: return a (malloced) string containing most of
- * the encoding options */
-char *x264_param2string( x264_param_t *p, int b_res );
 
 /* log */
+#define x264_log x264_template(log)
 void x264_log( x264_t *h, int i_level, const char *psz_fmt, ... );
 
-void x264_reduce_fraction( uint32_t *n, uint32_t *d );
-void x264_reduce_fraction64( uint64_t *n, uint64_t *d );
+#define x264_cavlc_init x264_template(cavlc_init)
 void x264_cavlc_init( x264_t *h );
+#define x264_cabac_init x264_template(cabac_init)
 void x264_cabac_init( x264_t *h );
 
 static ALWAYS_INLINE pixel x264_clip_pixel( int x )
@@ -274,97 +145,9 @@ static ALWAYS_INLINE pixel x264_clip_pixel( int x )
     return ( (x & ~PIXEL_MAX) ? (-x)>>31 & PIXEL_MAX : x );
 }
 
-static ALWAYS_INLINE int x264_clip3( int v, int i_min, int i_max )
-{
-    return ( (v < i_min) ? i_min : (v > i_max) ? i_max : v );
-}
-
-static ALWAYS_INLINE double x264_clip3f( double v, double f_min, double f_max )
-{
-    return ( (v < f_min) ? f_min : (v > f_max) ? f_max : v );
-}
-
-static ALWAYS_INLINE int x264_median( int a, int b, int c )
-{
-    int t = (a-b)&((a-b)>>31);
-    a -= t;
-    b += t;
-    b -= (b-c)&((b-c)>>31);
-    b += (a-b)&((a-b)>>31);
-    return b;
-}
-
-static ALWAYS_INLINE void x264_median_mv( int16_t *dst, int16_t *a, int16_t *b, int16_t *c )
-{
-    dst[0] = x264_median( a[0], b[0], c[0] );
-    dst[1] = x264_median( a[1], b[1], c[1] );
-}
-
-static ALWAYS_INLINE int x264_predictor_difference( int16_t (*mvc)[2], intptr_t i_mvc )
-{
-    int sum = 0;
-    for( int i = 0; i < i_mvc-1; i++ )
-    {
-        sum += abs( mvc[i][0] - mvc[i+1][0] )
-             + abs( mvc[i][1] - mvc[i+1][1] );
-    }
-    return sum;
-}
-
-static ALWAYS_INLINE uint16_t x264_cabac_mvd_sum( uint8_t *mvdleft, uint8_t *mvdtop )
-{
-    int amvd0 = mvdleft[0] + mvdtop[0];
-    int amvd1 = mvdleft[1] + mvdtop[1];
-    amvd0 = (amvd0 > 2) + (amvd0 > 32);
-    amvd1 = (amvd1 > 2) + (amvd1 > 32);
-    return amvd0 + (amvd1<<8);
-}
-
-extern const uint8_t x264_exp2_lut[64];
-extern const float x264_log2_lut[128];
-extern const float x264_log2_lz_lut[32];
-
-/* Not a general-purpose function; multiplies input by -1/6 to convert
- * qp to qscale. */
-static ALWAYS_INLINE int x264_exp2fix8( float x )
-{
-    int i = x*(-64.f/6.f) + 512.5f;
-    if( i < 0 ) return 0;
-    if( i > 1023 ) return 0xffff;
-    return (x264_exp2_lut[i&63]+256) << (i>>6) >> 8;
-}
-
-static ALWAYS_INLINE float x264_log2( uint32_t x )
-{
-    int lz = x264_clz( x );
-    return x264_log2_lut[(x<<lz>>24)&0x7f] + x264_log2_lz_lut[lz];
-}
-
 /****************************************************************************
  *
  ****************************************************************************/
-enum slice_type_e
-{
-    SLICE_TYPE_P  = 0,
-    SLICE_TYPE_B  = 1,
-    SLICE_TYPE_I  = 2,
-};
-
-static const char slice_type_to_char[] = { 'P', 'B', 'I' };
-
-enum sei_payload_type_e
-{
-    SEI_BUFFERING_PERIOD       = 0,
-    SEI_PIC_TIMING             = 1,
-    SEI_PAN_SCAN_RECT          = 2,
-    SEI_FILLER                 = 3,
-    SEI_USER_DATA_REGISTERED   = 4,
-    SEI_USER_DATA_UNREGISTERED = 5,
-    SEI_RECOVERY_POINT         = 6,
-    SEI_DEC_REF_PIC_MARKING    = 7,
-    SEI_FRAME_PACKING          = 45,
-};
-
 typedef struct
 {
     x264_sps_t *sps;
@@ -1019,4 +802,3 @@ static int ALWAYS_INLINE x264_predictor_clip( int16_t (*dst)[2], int16_t (*mvc)[
 #include "rectangle.h"
 
 #endif
-
index f365482fff7590c6a6f9750690923999c3ed5bed..fc233b6289685b8a21ec94867950c655f810cd7d 100644 (file)
@@ -25,7 +25,7 @@
  * For more information, contact us at licensing@x264.com.
  *****************************************************************************/
 
-#include "common.h"
+#include "base.h"
 
 #if HAVE_POSIXTHREAD && SYS_LINUX
 #include <sched.h>
@@ -296,7 +296,7 @@ uint32_t x264_cpu_detect( void )
         else if( cache == 64 )
             cpu |= X264_CPU_CACHELINE_64;
         else
-            x264_log( NULL, X264_LOG_WARNING, "unable to determine cacheline size\n" );
+            x264_log_internal( X264_LOG_WARNING, "unable to determine cacheline size\n" );
     }
 
 #if STACK_ALIGNMENT < 16
index 70853bf9325887fd969e78b03d745da7d57014c7..860b0fd418155ff6e6ccd3bfe8cb31433a862160 100644 (file)
 #   include "mips/dct.h"
 #endif
 
-/* the inverse of the scaling factors introduced by 8x8 fdct */
-/* uint32 is for the asm implementation of trellis. the actual values fit in uint16. */
-#define W(i) (i==0 ? FIX8(1.0000) :\
-              i==1 ? FIX8(0.8859) :\
-              i==2 ? FIX8(1.6000) :\
-              i==3 ? FIX8(0.9415) :\
-              i==4 ? FIX8(1.2651) :\
-              i==5 ? FIX8(1.1910) :0)
-const uint32_t x264_dct8_weight_tab[64] = {
-    W(0), W(3), W(4), W(3),  W(0), W(3), W(4), W(3),
-    W(3), W(1), W(5), W(1),  W(3), W(1), W(5), W(1),
-    W(4), W(5), W(2), W(5),  W(4), W(5), W(2), W(5),
-    W(3), W(1), W(5), W(1),  W(3), W(1), W(5), W(1),
-
-    W(0), W(3), W(4), W(3),  W(0), W(3), W(4), W(3),
-    W(3), W(1), W(5), W(1),  W(3), W(1), W(5), W(1),
-    W(4), W(5), W(2), W(5),  W(4), W(5), W(2), W(5),
-    W(3), W(1), W(5), W(1),  W(3), W(1), W(5), W(1)
-};
-#undef W
-
-#define W(i) (i==0 ? FIX8(1.76777) :\
-              i==1 ? FIX8(1.11803) :\
-              i==2 ? FIX8(0.70711) :0)
-const uint32_t x264_dct4_weight_tab[16] = {
-    W(0), W(1), W(0), W(1),
-    W(1), W(2), W(1), W(2),
-    W(0), W(1), W(0), W(1),
-    W(1), W(2), W(1), W(2)
-};
-#undef W
-
-/* inverse squared */
-#define W(i) (i==0 ? FIX8(3.125) :\
-              i==1 ? FIX8(1.25) :\
-              i==2 ? FIX8(0.5) :0)
-const uint32_t x264_dct4_weight2_tab[16] = {
-    W(0), W(1), W(0), W(1),
-    W(1), W(2), W(1), W(2),
-    W(0), W(1), W(0), W(1),
-    W(1), W(2), W(1), W(2)
-};
-#undef W
-
-#define W(i) (i==0 ? FIX8(1.00000) :\
-              i==1 ? FIX8(0.78487) :\
-              i==2 ? FIX8(2.56132) :\
-              i==3 ? FIX8(0.88637) :\
-              i==4 ? FIX8(1.60040) :\
-              i==5 ? FIX8(1.41850) :0)
-const uint32_t x264_dct8_weight2_tab[64] = {
-    W(0), W(3), W(4), W(3),  W(0), W(3), W(4), W(3),
-    W(3), W(1), W(5), W(1),  W(3), W(1), W(5), W(1),
-    W(4), W(5), W(2), W(5),  W(4), W(5), W(2), W(5),
-    W(3), W(1), W(5), W(1),  W(3), W(1), W(5), W(1),
-
-    W(0), W(3), W(4), W(3),  W(0), W(3), W(4), W(3),
-    W(3), W(1), W(5), W(1),  W(3), W(1), W(5), W(1),
-    W(4), W(5), W(2), W(5),  W(4), W(5), W(2), W(5),
-    W(3), W(1), W(5), W(1),  W(3), W(1), W(5), W(1)
-};
-#undef W
-
-
 static void dct4x4dc( dctcoef d[16] )
 {
     dctcoef tmp[16];
index d443e228b3fa39c83de7e90fd38f5c754e0e4039..932d5b65979374fe48935925cab82ae037b17b97 100644 (file)
 #ifndef X264_DCT_H
 #define X264_DCT_H
 
-extern const uint32_t x264_dct4_weight_tab[16];
-extern const uint32_t x264_dct8_weight_tab[64];
-extern const uint32_t x264_dct4_weight2_tab[16];
-extern const uint32_t x264_dct8_weight2_tab[64];
-
 typedef struct
 {
     // pix1  stride = FENC_STRIDE
@@ -74,7 +69,9 @@ typedef struct
 
 } x264_zigzag_function_t;
 
+#define x264_dct_init x264_template(dct_init)
 void x264_dct_init( int cpu, x264_dct_function_t *dctf );
+#define x264_zigzag_init x264_template(zigzag_init)
 void x264_zigzag_init( int cpu, x264_zigzag_function_t *pf_progressive, x264_zigzag_function_t *pf_interlaced );
 
 #endif
index cd80199d3ee5031c2ffccfc950406e3e07eef7c7..41a1534bdb2d582351439f043c7e9cb3cdc691f0 100644 (file)
@@ -652,117 +652,19 @@ void x264_macroblock_deblock( x264_t *h )
 }
 
 #if HAVE_MMX
-void x264_deblock_v_luma_sse2( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_v_luma_avx ( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_h_luma_sse2( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_h_luma_avx ( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_v_chroma_sse2( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_v_chroma_avx ( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_h_chroma_sse2( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_h_chroma_avx ( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_h_chroma_mbaff_sse2( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_h_chroma_mbaff_avx ( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_h_chroma_422_mmx2( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_h_chroma_422_sse2( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_h_chroma_422_avx ( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_v_luma_intra_sse2( pixel *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_v_luma_intra_avx ( pixel *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_h_luma_intra_sse2( pixel *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_h_luma_intra_avx ( pixel *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_v_chroma_intra_sse2( pixel *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_v_chroma_intra_avx ( pixel *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_h_chroma_intra_sse2( pixel *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_h_chroma_intra_avx ( pixel *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_h_chroma_422_intra_mmx2( pixel *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_h_chroma_422_intra_sse2( pixel *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_h_chroma_422_intra_avx ( pixel *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_strength_sse2  ( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE],
-                                   int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][8][4],
-                                   int mvy_limit, int bframe );
-void x264_deblock_strength_ssse3 ( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE],
-                                   int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][8][4],
-                                   int mvy_limit, int bframe );
-void x264_deblock_strength_avx   ( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE],
-                                   int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][8][4],
-                                   int mvy_limit, int bframe );
-void x264_deblock_strength_avx2  ( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE],
-                                   int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][8][4],
-                                   int mvy_limit, int bframe );
-void x264_deblock_strength_avx512( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE],
-                                   int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][8][4],
-                                   int mvy_limit, int bframe );
-
-void x264_deblock_h_chroma_intra_mbaff_mmx2( pixel *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_h_chroma_intra_mbaff_sse2( pixel *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_h_chroma_intra_mbaff_avx ( pixel *pix, intptr_t stride, int alpha, int beta );
-#if ARCH_X86
-void x264_deblock_h_luma_mmx2( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_v8_luma_mmx2( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_v_chroma_mmx2( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_h_chroma_mmx2( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_h_chroma_mbaff_mmx2( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_h_luma_intra_mmx2( pixel *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_v8_luma_intra_mmx2( uint8_t *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_v_chroma_intra_mmx2( pixel *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_h_chroma_intra_mmx2( pixel *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_h_chroma_intra_mbaff_mmx2( pixel *pix, intptr_t stride, int alpha, int beta );
-
-#if HIGH_BIT_DEPTH
-void x264_deblock_v_luma_mmx2( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_v_luma_intra_mmx2( pixel *pix, intptr_t stride, int alpha, int beta );
-#else
-// FIXME this wrapper has a significant cpu cost
-static void x264_deblock_v_luma_mmx2( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 )
-{
-    x264_deblock_v8_luma_mmx2( pix,   stride, alpha, beta, tc0   );
-    x264_deblock_v8_luma_mmx2( pix+8, stride, alpha, beta, tc0+2 );
-}
-static void x264_deblock_v_luma_intra_mmx2( uint8_t *pix, intptr_t stride, int alpha, int beta )
-{
-    x264_deblock_v8_luma_intra_mmx2( pix,   stride, alpha, beta );
-    x264_deblock_v8_luma_intra_mmx2( pix+8, stride, alpha, beta );
-}
-#endif // HIGH_BIT_DEPTH
+#include "x86/deblock.h"
 #endif
-#endif
-
 #if ARCH_PPC
-void x264_deblock_v_luma_altivec( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_h_luma_altivec( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-#endif // ARCH_PPC
-
-#if HAVE_ARMV6 || ARCH_AARCH64
-void x264_deblock_v_luma_neon  ( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_h_luma_neon  ( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_v_chroma_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_h_chroma_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_strength_neon( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE],
-                                 int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][8][4],
-                                 int mvy_limit, int bframe );
-void x264_deblock_h_chroma_422_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_h_chroma_mbaff_neon( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_h_chroma_intra_mbaff_neon( uint8_t *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_h_chroma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_h_chroma_422_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_v_chroma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_h_luma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_v_luma_intra_neon( uint8_t *pix, intptr_t stride, int alpha, int beta );
+#include "ppc/deblock.h"
 #endif
-
-#if !HIGH_BIT_DEPTH
-#if HAVE_MSA
-void x264_deblock_v_luma_msa( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_h_luma_msa( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_v_chroma_msa( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_h_chroma_msa( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
-void x264_deblock_v_luma_intra_msa( uint8_t *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_h_luma_intra_msa( uint8_t *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_v_chroma_intra_msa( uint8_t *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_h_chroma_intra_msa( uint8_t *pix, intptr_t stride, int alpha, int beta );
-void x264_deblock_strength_msa( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE],
-                                int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][8][4], int mvy_limit,
-                                int bframe );
+#if HAVE_ARMV6
+#include "arm/deblock.h"
 #endif
+#if ARCH_AARCH64
+#include "aarch64/deblock.h"
+#endif
+#if HAVE_MSA
+#include "mips/deblock.h"
 #endif
 
 void x264_deblock_init( int cpu, x264_deblock_function_t *pf, int b_mbaff )
index 18eb427f30059fd82bacd4974c575249d20bc882..7d60ac464bdd14891b1685f277be4c82e3fa6c98 100644 (file)
@@ -216,47 +216,79 @@ typedef struct
                               int bframe );
 } x264_deblock_function_t;
 
+#define x264_frame_delete x264_template(frame_delete)
 void          x264_frame_delete( x264_frame_t *frame );
 
+#define x264_frame_copy_picture x264_template(frame_copy_picture)
 int           x264_frame_copy_picture( x264_t *h, x264_frame_t *dst, x264_picture_t *src );
 
+#define x264_frame_expand_border x264_template(frame_expand_border)
 void          x264_frame_expand_border( x264_t *h, x264_frame_t *frame, int mb_y );
+#define x264_frame_expand_border_filtered x264_template(frame_expand_border_filtered)
 void          x264_frame_expand_border_filtered( x264_t *h, x264_frame_t *frame, int mb_y, int b_end );
+#define x264_frame_expand_border_lowres x264_template(frame_expand_border_lowres)
 void          x264_frame_expand_border_lowres( x264_frame_t *frame );
+#define x264_frame_expand_border_chroma x264_template(frame_expand_border_chroma)
 void          x264_frame_expand_border_chroma( x264_t *h, x264_frame_t *frame, int plane );
+#define x264_frame_expand_border_mod16 x264_template(frame_expand_border_mod16)
 void          x264_frame_expand_border_mod16( x264_t *h, x264_frame_t *frame );
+#define x264_expand_border_mbpair x264_template(expand_border_mbpair)
 void          x264_expand_border_mbpair( x264_t *h, int mb_x, int mb_y );
 
+#define x264_frame_deblock_row x264_template(frame_deblock_row)
 void          x264_frame_deblock_row( x264_t *h, int mb_y );
+#define x264_macroblock_deblock x264_template(macroblock_deblock)
 void          x264_macroblock_deblock( x264_t *h );
 
+#define x264_frame_filter x264_template(frame_filter)
 void          x264_frame_filter( x264_t *h, x264_frame_t *frame, int mb_y, int b_end );
+#define x264_frame_init_lowres x264_template(frame_init_lowres)
 void          x264_frame_init_lowres( x264_t *h, x264_frame_t *frame );
 
+#define x264_deblock_init x264_template(deblock_init)
 void          x264_deblock_init( int cpu, x264_deblock_function_t *pf, int b_mbaff );
 
+#define x264_frame_cond_broadcast x264_template(frame_cond_broadcast)
 void          x264_frame_cond_broadcast( x264_frame_t *frame, int i_lines_completed );
+#define x264_frame_cond_wait x264_template(frame_cond_wait)
 void          x264_frame_cond_wait( x264_frame_t *frame, int i_lines_completed );
+#define x264_frame_new_slice x264_template(frame_new_slice)
 int           x264_frame_new_slice( x264_t *h, x264_frame_t *frame );
 
+#define x264_threadslice_cond_broadcast x264_template(threadslice_cond_broadcast)
 void          x264_threadslice_cond_broadcast( x264_t *h, int pass );
+#define x264_threadslice_cond_wait x264_template(threadslice_cond_wait)
 void          x264_threadslice_cond_wait( x264_t *h, int pass );
 
+#define x264_frame_push x264_template(frame_push)
 void          x264_frame_push( x264_frame_t **list, x264_frame_t *frame );
+#define x264_frame_pop x264_template(frame_pop)
 x264_frame_t *x264_frame_pop( x264_frame_t **list );
+#define x264_frame_unshift x264_template(frame_unshift)
 void          x264_frame_unshift( x264_frame_t **list, x264_frame_t *frame );
+#define x264_frame_shift x264_template(frame_shift)
 x264_frame_t *x264_frame_shift( x264_frame_t **list );
+#define x264_frame_push_unused x264_template(frame_push_unused)
 void          x264_frame_push_unused( x264_t *h, x264_frame_t *frame );
+#define x264_frame_push_blank_unused x264_template(frame_push_blank_unused)
 void          x264_frame_push_blank_unused( x264_t *h, x264_frame_t *frame );
+#define x264_frame_pop_blank_unused x264_template(frame_pop_blank_unused)
 x264_frame_t *x264_frame_pop_blank_unused( x264_t *h );
+#define x264_weight_scale_plane x264_template(weight_scale_plane)
 void x264_weight_scale_plane( x264_t *h, pixel *dst, intptr_t i_dst_stride, pixel *src, intptr_t i_src_stride,
                               int i_width, int i_height, x264_weight_t *w );
+#define x264_frame_pop_unused x264_template(frame_pop_unused)
 x264_frame_t *x264_frame_pop_unused( x264_t *h, int b_fdec );
+#define x264_frame_delete_list x264_template(frame_delete_list)
 void          x264_frame_delete_list( x264_frame_t **list );
 
+#define x264_sync_frame_list_init x264_template(sync_frame_list_init)
 int           x264_sync_frame_list_init( x264_sync_frame_list_t *slist, int nelem );
+#define x264_sync_frame_list_delete x264_template(sync_frame_list_delete)
 void          x264_sync_frame_list_delete( x264_sync_frame_list_t *slist );
+#define x264_sync_frame_list_push x264_template(sync_frame_list_push)
 void          x264_sync_frame_list_push( x264_sync_frame_list_t *slist, x264_frame_t *frame );
+#define x264_sync_frame_list_pop x264_template(sync_frame_list_pop)
 x264_frame_t *x264_sync_frame_list_pop( x264_sync_frame_list_t *slist );
 
 #endif
index f1dfb275f99111d63eb726a0dfad96703c756879..8d872f188e5d5671976e5b1520421d4bc62f5c69 100644 (file)
@@ -299,38 +299,54 @@ static const uint8_t ctx_cat_plane[6][3] =
 };
 
 /* Per-frame allocation: is allocated per-thread only in frame-threads mode. */
+#define x264_macroblock_cache_allocate x264_template(macroblock_cache_allocate)
 int  x264_macroblock_cache_allocate( x264_t *h );
+#define x264_macroblock_cache_free x264_template(macroblock_cache_free)
 void x264_macroblock_cache_free( x264_t *h );
 
 /* Per-thread allocation: is allocated per-thread even in sliced-threads mode. */
+#define x264_macroblock_thread_allocate x264_template(macroblock_thread_allocate)
 int  x264_macroblock_thread_allocate( x264_t *h, int b_lookahead );
+#define x264_macroblock_thread_free x264_template(macroblock_thread_free)
 void x264_macroblock_thread_free( x264_t *h, int b_lookahead );
 
+#define x264_macroblock_slice_init x264_template(macroblock_slice_init)
 void x264_macroblock_slice_init( x264_t *h );
+#define x264_macroblock_thread_init x264_template(macroblock_thread_init)
 void x264_macroblock_thread_init( x264_t *h );
+#define x264_macroblock_cache_load_interlaced x264_template(macroblock_cache_load_interlaced)
 void x264_macroblock_cache_load_progressive( x264_t *h, int mb_x, int mb_y );
+#define x264_macroblock_cache_load_progressive x264_template(macroblock_cache_load_progressive)
 void x264_macroblock_cache_load_interlaced( x264_t *h, int mb_x, int mb_y );
+#define x264_macroblock_deblock_strength x264_template(macroblock_deblock_strength)
 void x264_macroblock_deblock_strength( x264_t *h );
+#define x264_macroblock_cache_save x264_template(macroblock_cache_save)
 void x264_macroblock_cache_save( x264_t *h );
 
+#define x264_macroblock_bipred_init x264_template(macroblock_bipred_init)
 void x264_macroblock_bipred_init( x264_t *h );
 
+#define x264_prefetch_fenc x264_template(prefetch_fenc)
 void x264_prefetch_fenc( x264_t *h, x264_frame_t *fenc, int i_mb_x, int i_mb_y );
 
+#define x264_copy_column8 x264_template(copy_column8)
 void x264_copy_column8( pixel *dst, pixel *src );
 
 /* x264_mb_predict_mv_16x16:
  *      set mvp with predicted mv for D_16x16 block
  *      h->mb. need only valid values from other blocks */
+#define x264_mb_predict_mv_16x16 x264_template(mb_predict_mv_16x16)
 void x264_mb_predict_mv_16x16( x264_t *h, int i_list, int i_ref, int16_t mvp[2] );
 /* x264_mb_predict_mv_pskip:
  *      set mvp with predicted mv for P_SKIP
  *      h->mb. need only valid values from other blocks */
+#define x264_mb_predict_mv_pskip x264_template(mb_predict_mv_pskip)
 void x264_mb_predict_mv_pskip( x264_t *h, int16_t mv[2] );
 /* x264_mb_predict_mv:
  *      set mvp with predicted mv for all blocks except SKIP and DIRECT
  *      h->mb. need valid ref/partition/sub of current block to be valid
  *      and valid mv/ref from other blocks. */
+#define x264_mb_predict_mv x264_template(mb_predict_mv)
 void x264_mb_predict_mv( x264_t *h, int i_list, int idx, int i_width, int16_t mvp[2] );
 /* x264_mb_predict_mv_direct16x16:
  *      set h->mb.cache.mv and h->mb.cache.ref for B_SKIP or B_DIRECT
@@ -338,14 +354,18 @@ void x264_mb_predict_mv( x264_t *h, int i_list, int idx, int i_width, int16_t mv
  *      return 1 on success, 0 on failure.
  *      if b_changed != NULL, set it to whether refs or mvs differ from
  *      before this functioncall. */
+#define x264_mb_predict_mv_direct16x16 x264_template(mb_predict_mv_direct16x16)
 int x264_mb_predict_mv_direct16x16( x264_t *h, int *b_changed );
 /* x264_mb_predict_mv_ref16x16:
  *      set mvc with D_16x16 prediction.
  *      uses all neighbors, even those that didn't end up using this ref.
  *      h->mb. need only valid values from other blocks */
+#define x264_mb_predict_mv_ref16x16 x264_template(mb_predict_mv_ref16x16)
 void x264_mb_predict_mv_ref16x16( x264_t *h, int i_list, int i_ref, int16_t mvc[8][2], int *i_mvc );
 
+#define x264_mb_mc x264_template(mb_mc)
 void x264_mb_mc( x264_t *h );
+#define x264_mb_mc_8x8 x264_template(mb_mc_8x8)
 void x264_mb_mc_8x8( x264_t *h, int i8 );
 
 static ALWAYS_INLINE uint32_t pack16to32( uint32_t a, uint32_t b )
index 31a14935f443196f3e4c4b3810278388538d2c11..38875b9aaad49473a22a927a3f56a5f6420fed6f 100644 (file)
@@ -192,9 +192,6 @@ static void hpel_filter( pixel *dsth, pixel *dstv, pixel *dstc, pixel *src,
     }
 }
 
-const uint8_t x264_hpel_ref0[16] = {0,1,1,1,0,1,1,1,2,3,3,3,0,1,1,1};
-const uint8_t x264_hpel_ref1[16] = {0,0,1,0,2,2,3,2,2,2,3,2,2,2,3,2};
-
 static void mc_luma( pixel *dst,    intptr_t i_dst_stride,
                      pixel *src[4], intptr_t i_src_stride,
                      int mvx, int mvy,
index bbc8d27eea24903fb532bfe70232c0bb73ec4613..8a33929cea9abc73cfd09aa98482625501d975a2 100644 (file)
@@ -34,6 +34,7 @@ do\
     MC_CLIP_ADD((s)[1], (x)[1]);\
 } while( 0 )
 
+#define x264_mbtree_propagate_list_internal_neon x264_template(mbtree_propagate_list_internal_neon)
 #define PROPAGATE_LIST(cpu)\
 void x264_mbtree_propagate_list_internal_##cpu( int16_t (*mvs)[2], int16_t *propagate_amount,\
                                                 uint16_t *lowres_costs, int16_t *output,\
@@ -100,6 +101,7 @@ static void mbtree_propagate_list_##cpu( x264_t *h, uint16_t *ref_costs, int16_t
     }\
 }
 
+#define x264_plane_copy_c x264_template(plane_copy_c)
 void x264_plane_copy_c( pixel *, intptr_t, pixel *, intptr_t, int w, int h );
 
 #define PLANE_COPY(align, cpu)\
@@ -128,6 +130,7 @@ static void plane_copy_##cpu( pixel *dst, intptr_t i_dst, pixel *src, intptr_t i
     }\
 }
 
+#define x264_plane_copy_swap_c x264_template(plane_copy_swap_c)
 void x264_plane_copy_swap_c( pixel *, intptr_t, pixel *, intptr_t, int w, int h );
 
 #define PLANE_COPY_SWAP(align, cpu)\
@@ -160,6 +163,7 @@ static void plane_copy_swap_##cpu( pixel *dst, intptr_t i_dst, pixel *src, intpt
         x264_plane_copy_swap_c( dst, i_dst, src, i_src, w, h );\
 }
 
+#define x264_plane_copy_deinterleave_c x264_template(plane_copy_deinterleave_c)
 void x264_plane_copy_deinterleave_c( pixel *dsta, intptr_t i_dsta, pixel *dstb, intptr_t i_dstb,
                                      pixel *src, intptr_t i_src, int w, int h );
 
@@ -193,6 +197,7 @@ static void plane_copy_deinterleave_yuyv_##cpu( pixel *dsta, intptr_t i_dsta, pi
         x264_plane_copy_deinterleave_c( dsta, i_dsta, dstb, i_dstb, src, i_src, w, h );\
 }
 
+#define x264_plane_copy_interleave_c x264_template(plane_copy_interleave_c)
 void x264_plane_copy_interleave_c( pixel *dst,  intptr_t i_dst,
                                    pixel *srcu, intptr_t i_srcu,
                                    pixel *srcv, intptr_t i_srcv, int w, int h );
@@ -239,9 +244,8 @@ typedef struct x264_weight_t
     weight_fn_t *weightfn;
 } ALIGNED_16( x264_weight_t );
 
+#define x264_weight_none x264_template(weight_none)
 extern const x264_weight_t x264_weight_none[3];
-extern const uint8_t x264_hpel_ref0[16];
-extern const uint8_t x264_hpel_ref1[16];
 
 #define SET_WEIGHT( w, b, s, d, o )\
 {\
@@ -335,6 +339,7 @@ typedef struct
     void (*mbtree_fix8_unpack)( float *dst, uint16_t *src, int count );
 } x264_mc_functions_t;
 
+#define x264_mc_init x264_template(mc_init)
 void x264_mc_init( int cpu, x264_mc_functions_t *pf, int cpu_independent );
 
 #endif
index 699649fbb16257e9e412bf6bb444e0c9ed5d0005..5873f52f9cc6f5fb4b4fb09c182e123cb3086308 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "common/common.h"
 #include "macros.h"
+#include "dct.h"
 
 #if !HIGH_BIT_DEPTH
 #define AVC_ITRANS_H( in0, in1, in2, in3, out0, out1, out2, out3 )          \
index de535ae774aeb479fa2a867da563936c001a213e..4e96e7ef47f3c24dd7fc4a3e48e493ae09406571 100644 (file)
 #ifndef X264_MIPS_DCT_H
 #define X264_MIPS_DCT_H
 
+#define x264_dct4x4dc_msa x264_template(dct4x4dc_msa)
 void x264_dct4x4dc_msa( int16_t d[16] );
+#define x264_idct4x4dc_msa x264_template(idct4x4dc_msa)
 void x264_idct4x4dc_msa( int16_t d[16] );
+#define x264_add4x4_idct_msa x264_template(add4x4_idct_msa)
 void x264_add4x4_idct_msa( uint8_t *p_dst, int16_t pi_dct[16] );
+#define x264_add8x8_idct_msa x264_template(add8x8_idct_msa)
 void x264_add8x8_idct_msa( uint8_t *p_dst, int16_t pi_dct[4][16] );
+#define x264_add16x16_idct_msa x264_template(add16x16_idct_msa)
 void x264_add16x16_idct_msa( uint8_t *p_dst, int16_t pi_dct[16][16] );
+#define x264_add8x8_idct8_msa x264_template(add8x8_idct8_msa)
 void x264_add8x8_idct8_msa( uint8_t *p_dst, int16_t pi_dct[64] );
+#define x264_add16x16_idct8_msa x264_template(add16x16_idct8_msa)
 void x264_add16x16_idct8_msa( uint8_t *p_dst, int16_t pi_dct[4][64] );
+#define x264_add8x8_idct_dc_msa x264_template(add8x8_idct_dc_msa)
 void x264_add8x8_idct_dc_msa( uint8_t *p_dst, int16_t pi_dct[4] );
+#define x264_add16x16_idct_dc_msa x264_template(add16x16_idct_dc_msa)
 void x264_add16x16_idct_dc_msa( uint8_t *p_dst, int16_t pi_dct[16] );
+#define x264_sub4x4_dct_msa x264_template(sub4x4_dct_msa)
 void x264_sub4x4_dct_msa( int16_t p_dst[16], uint8_t *p_src, uint8_t *p_ref );
+#define x264_sub8x8_dct_msa x264_template(sub8x8_dct_msa)
 void x264_sub8x8_dct_msa( int16_t p_dst[4][16], uint8_t *p_src,
                           uint8_t *p_ref );
+#define x264_sub16x16_dct_msa x264_template(sub16x16_dct_msa)
 void x264_sub16x16_dct_msa( int16_t p_dst[16][16], uint8_t *p_src,
                             uint8_t *p_ref );
+#define x264_sub8x8_dct_dc_msa x264_template(sub8x8_dct_dc_msa)
 void x264_sub8x8_dct_dc_msa( int16_t pi_dct[4], uint8_t *p_pix1,
                              uint8_t *p_pix2 );
+#define x264_sub8x16_dct_dc_msa x264_template(sub8x16_dct_dc_msa)
 void x264_sub8x16_dct_dc_msa( int16_t pi_dct[8], uint8_t *p_pix1,
                               uint8_t *p_pix2 );
+#define x264_zigzag_scan_4x4_frame_msa x264_template(zigzag_scan_4x4_frame_msa)
 void x264_zigzag_scan_4x4_frame_msa( int16_t pi_level[16], int16_t pi_dct[16] );
 
 #endif
index ee690599163d164a67a3ad5fbeb76a80ae06a712..99e60e91cd1334dbb39095a6e811be4b54e9c1ce 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "common/common.h"
 #include "macros.h"
+#include "deblock.h"
 
 #if !HIGH_BIT_DEPTH
 #define AVC_LPF_P0P1P2_OR_Q0Q1Q2( p3_or_q3_org_in, p0_or_q0_org_in,           \
diff --git a/common/mips/deblock.h b/common/mips/deblock.h
new file mode 100644 (file)
index 0000000..2da299c
--- /dev/null
@@ -0,0 +1,52 @@
+/*****************************************************************************
+ * deblock.h: msa deblocking
+ *****************************************************************************
+ * Copyright (C) 2017 x264 project
+ *
+ * Authors: Anton Mitrofanov <BugMaster@narod.ru>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@x264.com.
+ *****************************************************************************/
+
+#ifndef X264_MIPS_DEBLOCK_H
+#define X264_MIPS_DEBLOCK_H
+
+#if !HIGH_BIT_DEPTH
+#define x264_deblock_v_luma_msa x264_template(deblock_v_luma_msa)
+void x264_deblock_v_luma_msa( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_h_luma_msa x264_template(deblock_h_luma_msa)
+void x264_deblock_h_luma_msa( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_v_chroma_msa x264_template(deblock_v_chroma_msa)
+void x264_deblock_v_chroma_msa( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_h_chroma_msa x264_template(deblock_h_chroma_msa)
+void x264_deblock_h_chroma_msa( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_v_luma_intra_msa x264_template(deblock_v_luma_intra_msa)
+void x264_deblock_v_luma_intra_msa( uint8_t *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_h_luma_intra_msa x264_template(deblock_h_luma_intra_msa)
+void x264_deblock_h_luma_intra_msa( uint8_t *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_v_chroma_intra_msa x264_template(deblock_v_chroma_intra_msa)
+void x264_deblock_v_chroma_intra_msa( uint8_t *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_h_chroma_intra_msa x264_template(deblock_h_chroma_intra_msa)
+void x264_deblock_h_chroma_intra_msa( uint8_t *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_strength_msa x264_template(deblock_strength_msa)
+void x264_deblock_strength_msa( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE],
+                                int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][8][4], int mvy_limit,
+                                int bframe );
+#endif
+
+#endif
index 964c21eb7f1f2f7904a627f9d020186c293a4f83..d57bef4e3c1658d146c76a74546a97d71ab152d9 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef X264_MIPS_MC_H
 #define X264_MIPS_MC_H
 
+#define x264_mc_init_mips x264_template(mc_init_mips)
 void x264_mc_init_mips( int cpu, x264_mc_functions_t *pf );
 
 #endif
index a81bd8a0dea1809946c4b33e3934e263de27a045..7d4a282e1f4242efd125bd0a510537cdb77ecef8 100644 (file)
 #ifndef X264_MIPS_SAD_H
 #define X264_MIPS_SAD_H
 
+#define x264_pixel_sad_16x16_msa x264_template(pixel_sad_16x16_msa)
 int32_t x264_pixel_sad_16x16_msa( uint8_t *p_src, intptr_t i_src_stride,
                                   uint8_t *p_ref, intptr_t i_ref_stride );
+#define x264_pixel_sad_16x8_msa x264_template(pixel_sad_16x8_msa)
 int32_t x264_pixel_sad_16x8_msa( uint8_t *p_src, intptr_t i_src_stride,
                                  uint8_t *p_ref, intptr_t i_ref_stride );
+#define x264_pixel_sad_8x16_msa x264_template(pixel_sad_8x16_msa)
 int32_t x264_pixel_sad_8x16_msa( uint8_t *p_src, intptr_t i_src_stride,
                                  uint8_t *p_ref, intptr_t i_ref_stride );
+#define x264_pixel_sad_8x8_msa x264_template(pixel_sad_8x8_msa)
 int32_t x264_pixel_sad_8x8_msa( uint8_t *p_src, intptr_t i_src_stride,
                                 uint8_t *p_ref, intptr_t i_ref_stride );
+#define x264_pixel_sad_8x4_msa x264_template(pixel_sad_8x4_msa)
 int32_t x264_pixel_sad_8x4_msa( uint8_t *p_src, intptr_t i_src_stride,
                                 uint8_t *p_ref, intptr_t i_ref_stride );
+#define x264_pixel_sad_4x16_msa x264_template(pixel_sad_4x16_msa)
 int32_t x264_pixel_sad_4x16_msa( uint8_t *p_src, intptr_t i_src_stride,
                                  uint8_t *p_ref, intptr_t i_ref_stride );
+#define x264_pixel_sad_4x8_msa x264_template(pixel_sad_4x8_msa)
 int32_t x264_pixel_sad_4x8_msa( uint8_t *p_src, intptr_t i_src_stride,
                                 uint8_t *p_ref, intptr_t i_ref_stride );
+#define x264_pixel_sad_4x4_msa x264_template(pixel_sad_4x4_msa)
 int32_t x264_pixel_sad_4x4_msa( uint8_t *p_src, intptr_t i_src_stride,
                                 uint8_t *p_ref, intptr_t i_ref_stride );
+#define x264_pixel_sad_x4_16x16_msa x264_template(pixel_sad_x4_16x16_msa)
 void x264_pixel_sad_x4_16x16_msa( uint8_t *p_src, uint8_t *p_ref0,
                                   uint8_t *p_ref1, uint8_t *p_ref2,
                                   uint8_t *p_ref3, intptr_t i_ref_stride,
                                   int32_t p_sad_array[4] );
+#define x264_pixel_sad_x4_16x8_msa x264_template(pixel_sad_x4_16x8_msa)
 void x264_pixel_sad_x4_16x8_msa( uint8_t *p_src, uint8_t *p_ref0,
                                  uint8_t *p_ref1, uint8_t *p_ref2,
                                  uint8_t *p_ref3, intptr_t i_ref_stride,
                                  int32_t p_sad_array[4] );
+#define x264_pixel_sad_x4_8x16_msa x264_template(pixel_sad_x4_8x16_msa)
 void x264_pixel_sad_x4_8x16_msa( uint8_t *p_src, uint8_t *p_ref0,
                                  uint8_t *p_ref1, uint8_t *p_ref2,
                                  uint8_t *p_ref3, intptr_t i_ref_stride,
                                  int32_t p_sad_array[4] );
+#define x264_pixel_sad_x4_8x8_msa x264_template(pixel_sad_x4_8x8_msa)
 void x264_pixel_sad_x4_8x8_msa( uint8_t *p_src, uint8_t *p_ref0,
                                 uint8_t *p_ref1, uint8_t *p_ref2,
                                 uint8_t *p_ref3, intptr_t i_ref_stride,
                                 int32_t p_sad_array[4] );
+#define x264_pixel_sad_x4_8x4_msa x264_template(pixel_sad_x4_8x4_msa)
 void x264_pixel_sad_x4_8x4_msa( uint8_t *p_src, uint8_t *p_ref0,
                                 uint8_t *p_ref1, uint8_t *p_ref2,
                                 uint8_t *p_ref3, intptr_t i_ref_stride,
                                 int32_t p_sad_array[4] );
+#define x264_pixel_sad_x4_4x8_msa x264_template(pixel_sad_x4_4x8_msa)
 void x264_pixel_sad_x4_4x8_msa( uint8_t *p_src, uint8_t *p_ref0,
                                 uint8_t *p_ref1, uint8_t *p_ref2,
                                 uint8_t *p_ref3, intptr_t i_ref_stride,
                                 int32_t p_sad_array[4] );
+#define x264_pixel_sad_x4_4x4_msa x264_template(pixel_sad_x4_4x4_msa)
 void x264_pixel_sad_x4_4x4_msa( uint8_t *p_src, uint8_t *p_ref0,
                                 uint8_t *p_ref1, uint8_t *p_ref2,
                                 uint8_t *p_ref3, intptr_t i_ref_stride,
                                 int32_t p_sad_array[4] );
+#define x264_pixel_sad_x3_16x16_msa x264_template(pixel_sad_x3_16x16_msa)
 void x264_pixel_sad_x3_16x16_msa( uint8_t *p_src, uint8_t *p_ref0,
                                   uint8_t *p_ref1, uint8_t *p_ref2,
                                   intptr_t i_ref_stride,
                                   int32_t p_sad_array[3] );
+#define x264_pixel_sad_x3_16x8_msa x264_template(pixel_sad_x3_16x8_msa)
 void x264_pixel_sad_x3_16x8_msa( uint8_t *p_src, uint8_t *p_ref0,
                                  uint8_t *p_ref1, uint8_t *p_ref2,
                                  intptr_t i_ref_stride,
                                  int32_t p_sad_array[3] );
+#define x264_pixel_sad_x3_8x16_msa x264_template(pixel_sad_x3_8x16_msa)
 void x264_pixel_sad_x3_8x16_msa( uint8_t *p_src, uint8_t *p_ref0,
                                  uint8_t *p_ref1, uint8_t *p_ref2,
                                  intptr_t i_ref_stride,
                                  int32_t p_sad_array[3] );
+#define x264_pixel_sad_x3_8x8_msa x264_template(pixel_sad_x3_8x8_msa)
 void x264_pixel_sad_x3_8x8_msa( uint8_t *p_src, uint8_t *p_ref0,
                                 uint8_t *p_ref1, uint8_t *p_ref2,
                                 intptr_t i_ref_stride,
                                 int32_t p_sad_array[3] );
+#define x264_pixel_sad_x3_8x4_msa x264_template(pixel_sad_x3_8x4_msa)
 void x264_pixel_sad_x3_8x4_msa( uint8_t *p_src, uint8_t *p_ref0,
                                 uint8_t *p_ref1, uint8_t *p_ref2,
                                 intptr_t i_ref_stride,
                                 int32_t p_sad_array[3] );
+#define x264_pixel_sad_x3_4x8_msa x264_template(pixel_sad_x3_4x8_msa)
 void x264_pixel_sad_x3_4x8_msa( uint8_t *p_src, uint8_t *p_ref0,
                                 uint8_t *p_ref1, uint8_t *p_ref2,
                                 intptr_t i_ref_stride,
                                 int32_t p_sad_array[3] );
+#define x264_pixel_sad_x3_4x4_msa x264_template(pixel_sad_x3_4x4_msa)
 void x264_pixel_sad_x3_4x4_msa( uint8_t *p_src, uint8_t *p_ref0,
                                 uint8_t *p_ref1, uint8_t *p_ref2,
                                 intptr_t i_ref_stride,
                                 int32_t p_sad_array[3] );
+#define x264_pixel_ssd_16x16_msa x264_template(pixel_ssd_16x16_msa)
 int32_t x264_pixel_ssd_16x16_msa( uint8_t *p_src, intptr_t i_src_stride,
                                   uint8_t *p_ref, intptr_t i_ref_stride );
+#define x264_pixel_ssd_16x8_msa x264_template(pixel_ssd_16x8_msa)
 int32_t x264_pixel_ssd_16x8_msa( uint8_t *p_src, intptr_t i_src_stride,
                                  uint8_t *p_ref, intptr_t i_ref_stride );
+#define x264_pixel_ssd_8x16_msa x264_template(pixel_ssd_8x16_msa)
 int32_t x264_pixel_ssd_8x16_msa( uint8_t *p_src, intptr_t i_src_stride,
                                  uint8_t *p_ref, intptr_t i_ref_stride );
+#define x264_pixel_ssd_8x8_msa x264_template(pixel_ssd_8x8_msa)
 int32_t x264_pixel_ssd_8x8_msa( uint8_t *p_src, intptr_t i_src_stride,
                                 uint8_t *p_ref, intptr_t i_ref_stride );
+#define x264_pixel_ssd_8x4_msa x264_template(pixel_ssd_8x4_msa)
 int32_t x264_pixel_ssd_8x4_msa( uint8_t *p_src, intptr_t i_src_stride,
                                 uint8_t *p_ref, intptr_t i_ref_stride );
+#define x264_pixel_ssd_4x16_msa x264_template(pixel_ssd_4x16_msa)
 int32_t x264_pixel_ssd_4x16_msa( uint8_t *p_src, intptr_t i_src_stride,
                                  uint8_t *p_ref, intptr_t i_ref_stride );
+#define x264_pixel_ssd_4x8_msa x264_template(pixel_ssd_4x8_msa)
 int32_t x264_pixel_ssd_4x8_msa( uint8_t *p_src, intptr_t i_src_stride,
                                 uint8_t *p_ref, intptr_t i_ref_stride );
+#define x264_pixel_ssd_4x4_msa x264_template(pixel_ssd_4x4_msa)
 int32_t x264_pixel_ssd_4x4_msa( uint8_t *p_src, intptr_t i_src_stride,
                                 uint8_t *p_ref, intptr_t i_ref_stride );
+#define x264_intra_sad_x3_4x4_msa x264_template(intra_sad_x3_4x4_msa)
 void x264_intra_sad_x3_4x4_msa( uint8_t *p_enc, uint8_t *p_dec,
                                 int32_t p_sad_array[3] );
+#define x264_intra_sad_x3_16x16_msa x264_template(intra_sad_x3_16x16_msa)
 void x264_intra_sad_x3_16x16_msa( uint8_t *p_enc, uint8_t *p_dec,
                                   int32_t p_sad_array[3] );
+#define x264_intra_sad_x3_8x8_msa x264_template(intra_sad_x3_8x8_msa)
 void x264_intra_sad_x3_8x8_msa( uint8_t *p_enc, uint8_t p_edge[36],
                                 int32_t p_sad_array[3] );
+#define x264_intra_sad_x3_8x8c_msa x264_template(intra_sad_x3_8x8c_msa)
 void x264_intra_sad_x3_8x8c_msa( uint8_t *p_enc, uint8_t *p_dec,
                                  int32_t p_sad_array[3] );
+#define x264_ssim_4x4x2_core_msa x264_template(ssim_4x4x2_core_msa)
 void x264_ssim_4x4x2_core_msa( const uint8_t *p_pix1, intptr_t i_stride1,
                                const uint8_t *p_pix2, intptr_t i_stride2,
                                int32_t i_sums[2][4] );
+#define x264_pixel_hadamard_ac_8x8_msa x264_template(pixel_hadamard_ac_8x8_msa)
 uint64_t x264_pixel_hadamard_ac_8x8_msa( uint8_t *p_pix, intptr_t i_stride );
+#define x264_pixel_hadamard_ac_8x16_msa x264_template(pixel_hadamard_ac_8x16_msa)
 uint64_t x264_pixel_hadamard_ac_8x16_msa( uint8_t *p_pix, intptr_t i_stride );
+#define x264_pixel_hadamard_ac_16x8_msa x264_template(pixel_hadamard_ac_16x8_msa)
 uint64_t x264_pixel_hadamard_ac_16x8_msa( uint8_t *p_pix, intptr_t i_stride );
+#define x264_pixel_hadamard_ac_16x16_msa x264_template(pixel_hadamard_ac_16x16_msa)
 uint64_t x264_pixel_hadamard_ac_16x16_msa( uint8_t *p_pix, intptr_t i_stride );
+#define x264_pixel_satd_4x4_msa x264_template(pixel_satd_4x4_msa)
 int32_t x264_pixel_satd_4x4_msa( uint8_t *p_pix1, intptr_t i_stride,
                                  uint8_t *p_pix2, intptr_t i_stride2 );
+#define x264_pixel_satd_4x8_msa x264_template(pixel_satd_4x8_msa)
 int32_t x264_pixel_satd_4x8_msa( uint8_t *p_pix1, intptr_t i_stride,
                                  uint8_t *p_pix2, intptr_t i_stride2 );
+#define x264_pixel_satd_4x16_msa x264_template(pixel_satd_4x16_msa)
 int32_t x264_pixel_satd_4x16_msa( uint8_t *p_pix1, intptr_t i_stride,
                                   uint8_t *p_pix2, intptr_t i_stride2 );
+#define x264_pixel_satd_8x4_msa x264_template(pixel_satd_8x4_msa)
 int32_t x264_pixel_satd_8x4_msa( uint8_t *p_pix1, intptr_t i_stride,
                                  uint8_t *p_pix2, intptr_t i_stride2 );
+#define x264_pixel_satd_8x8_msa x264_template(pixel_satd_8x8_msa)
 int32_t x264_pixel_satd_8x8_msa( uint8_t *p_pix1, intptr_t i_stride,
                                  uint8_t *p_pix2, intptr_t i_stride2 );
+#define x264_pixel_satd_8x16_msa x264_template(pixel_satd_8x16_msa)
 int32_t x264_pixel_satd_8x16_msa( uint8_t *p_pix1, intptr_t i_stride,
                                   uint8_t *p_pix2, intptr_t i_stride2 );
+#define x264_pixel_satd_16x8_msa x264_template(pixel_satd_16x8_msa)
 int32_t x264_pixel_satd_16x8_msa( uint8_t *p_pix1, intptr_t i_stride,
                                   uint8_t *p_pix2, intptr_t i_stride2 );
+#define x264_pixel_satd_16x16_msa x264_template(pixel_satd_16x16_msa)
 int32_t x264_pixel_satd_16x16_msa( uint8_t *p_pix1, intptr_t i_stride,
                                    uint8_t *p_pix2, intptr_t i_stride2 );
+#define x264_pixel_sa8d_8x8_msa x264_template(pixel_sa8d_8x8_msa)
 int32_t x264_pixel_sa8d_8x8_msa( uint8_t *p_pix1, intptr_t i_stride,
                                  uint8_t *p_pix2, intptr_t i_stride2 );
+#define x264_pixel_sa8d_16x16_msa x264_template(pixel_sa8d_16x16_msa)
 int32_t x264_pixel_sa8d_16x16_msa( uint8_t *p_pix1, intptr_t i_stride,
                                    uint8_t *p_pix2, intptr_t i_stride2 );
+#define x264_intra_satd_x3_4x4_msa x264_template(intra_satd_x3_4x4_msa)
 void x264_intra_satd_x3_4x4_msa( uint8_t *p_enc, uint8_t *p_dec,
                                  int32_t p_sad_array[3] );
+#define x264_intra_satd_x3_16x16_msa x264_template(intra_satd_x3_16x16_msa)
 void x264_intra_satd_x3_16x16_msa( uint8_t *p_enc, uint8_t *p_dec,
                                    int32_t p_sad_array[3] );
+#define x264_intra_sa8d_x3_8x8_msa x264_template(intra_sa8d_x3_8x8_msa)
 void x264_intra_sa8d_x3_8x8_msa( uint8_t *p_enc, uint8_t p_edge[36],
                                  int32_t p_sad_array[3] );
+#define x264_intra_satd_x3_8x8c_msa x264_template(intra_satd_x3_8x8c_msa)
 void x264_intra_satd_x3_8x8c_msa( uint8_t *p_enc, uint8_t *p_dec,
                                   int32_t p_sad_array[3] );
+#define x264_pixel_var_16x16_msa x264_template(pixel_var_16x16_msa)
 uint64_t x264_pixel_var_16x16_msa( uint8_t *p_pix, intptr_t i_stride );
+#define x264_pixel_var_8x16_msa x264_template(pixel_var_8x16_msa)
 uint64_t x264_pixel_var_8x16_msa( uint8_t *p_pix, intptr_t i_stride );
+#define x264_pixel_var_8x8_msa x264_template(pixel_var_8x8_msa)
 uint64_t x264_pixel_var_8x8_msa( uint8_t *p_pix, intptr_t i_stride );
+#define x264_pixel_var2_8x16_msa x264_template(pixel_var2_8x16_msa)
 int32_t x264_pixel_var2_8x16_msa( uint8_t *p_pix1, intptr_t i_stride1,
                                   uint8_t *p_pix2, intptr_t i_stride2,
                                   int32_t *p_ssd );
+#define x264_pixel_var2_8x8_msa x264_template(pixel_var2_8x8_msa)
 int32_t x264_pixel_var2_8x8_msa( uint8_t *p_pix1, intptr_t i_stride1,
                                  uint8_t *p_pix2, intptr_t i_stride2,
                                  int32_t *p_ssd );
index 90f4dba93aed1f06fc74411e527a0515efbab08d..8d58b1d0c72d8e9882b687117d42559981df88c9 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "common/common.h"
 #include "macros.h"
+#include "predict.h"
 
 #if !HIGH_BIT_DEPTH
 static void intra_predict_vert_4x4_msa( uint8_t *p_src, uint8_t *p_dst,
index 4a29e82ec0b6727a2fbbf45cb007e05fc41f5979..52cab62421b0c51c0c1b9c7605d2719c94e41e0b 100644 (file)
 #ifndef X264_MIPS_PREDICT_H
 #define X264_MIPS_PREDICT_H
 
+#define x264_intra_predict_dc_16x16_msa x264_template(intra_predict_dc_16x16_msa)
 void x264_intra_predict_dc_16x16_msa( uint8_t *p_src );
+#define x264_intra_predict_dc_left_16x16_msa x264_template(intra_predict_dc_left_16x16_msa)
 void x264_intra_predict_dc_left_16x16_msa( uint8_t *p_src );
+#define x264_intra_predict_dc_top_16x16_msa x264_template(intra_predict_dc_top_16x16_msa)
 void x264_intra_predict_dc_top_16x16_msa( uint8_t *p_src );
+#define x264_intra_predict_dc_128_16x16_msa x264_template(intra_predict_dc_128_16x16_msa)
 void x264_intra_predict_dc_128_16x16_msa( uint8_t *p_src );
+#define x264_intra_predict_hor_16x16_msa x264_template(intra_predict_hor_16x16_msa)
 void x264_intra_predict_hor_16x16_msa( uint8_t *p_src );
+#define x264_intra_predict_vert_16x16_msa x264_template(intra_predict_vert_16x16_msa)
 void x264_intra_predict_vert_16x16_msa( uint8_t *p_src );
+#define x264_intra_predict_plane_16x16_msa x264_template(intra_predict_plane_16x16_msa)
 void x264_intra_predict_plane_16x16_msa( uint8_t *p_src );
+#define x264_intra_predict_dc_4blk_8x8_msa x264_template(intra_predict_dc_4blk_8x8_msa)
 void x264_intra_predict_dc_4blk_8x8_msa( uint8_t *p_src );
+#define x264_intra_predict_hor_8x8_msa x264_template(intra_predict_hor_8x8_msa)
 void x264_intra_predict_hor_8x8_msa( uint8_t *p_src );
+#define x264_intra_predict_vert_8x8_msa x264_template(intra_predict_vert_8x8_msa)
 void x264_intra_predict_vert_8x8_msa( uint8_t *p_src );
+#define x264_intra_predict_plane_8x8_msa x264_template(intra_predict_plane_8x8_msa)
 void x264_intra_predict_plane_8x8_msa( uint8_t *p_src );
+#define x264_intra_predict_ddl_8x8_msa x264_template(intra_predict_ddl_8x8_msa)
 void x264_intra_predict_ddl_8x8_msa( uint8_t *p_src, uint8_t pu_xyz[36] );
+#define x264_intra_predict_dc_8x8_msa x264_template(intra_predict_dc_8x8_msa)
 void x264_intra_predict_dc_8x8_msa( uint8_t *p_src, uint8_t pu_xyz[36] );
+#define x264_intra_predict_h_8x8_msa x264_template(intra_predict_h_8x8_msa)
 void x264_intra_predict_h_8x8_msa( uint8_t *p_src, uint8_t pu_xyz[36] );
+#define x264_intra_predict_v_8x8_msa x264_template(intra_predict_v_8x8_msa)
 void x264_intra_predict_v_8x8_msa( uint8_t *p_src, uint8_t pu_xyz[36] );
+#define x264_intra_predict_dc_4x4_msa x264_template(intra_predict_dc_4x4_msa)
 void x264_intra_predict_dc_4x4_msa( uint8_t *p_src );
+#define x264_intra_predict_hor_4x4_msa x264_template(intra_predict_hor_4x4_msa)
 void x264_intra_predict_hor_4x4_msa( uint8_t *p_src );
+#define x264_intra_predict_vert_4x4_msa x264_template(intra_predict_vert_4x4_msa)
 void x264_intra_predict_vert_4x4_msa( uint8_t *p_src );
 
 #endif
index eba843f22c58cf3ef02101557aa7c8a229d655f3..a8df7a72f06483f6369382db16e762b19a3b04d7 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "common/common.h"
 #include "macros.h"
+#include "quant.h"
 
 #if !HIGH_BIT_DEPTH
 static void avc_dequant_4x4_msa( int16_t *p_dct, int32_t pi_dequant_mf[6][16],
index 47e3d8aec35e82246821feb060b77fd670fafaff..f436a8d28976d272eb85c117045de133e2a73619 100644 (file)
 #ifndef X264_MIPS_QUANT_H
 #define X264_MIPS_QUANT_H
 
+#define x264_dequant_4x4_msa x264_template(dequant_4x4_msa)
 void x264_dequant_4x4_msa( int16_t *p_dct, int32_t pi_dequant_mf[6][16],
                            int32_t i_qp );
+#define x264_dequant_8x8_msa x264_template(dequant_8x8_msa)
 void x264_dequant_8x8_msa( int16_t *p_dct, int32_t pi_dequant_mf[6][64],
                            int32_t i_qp );
+#define x264_dequant_4x4_dc_msa x264_template(dequant_4x4_dc_msa)
 void x264_dequant_4x4_dc_msa( int16_t *p_dct, int32_t pi_dequant_mf[6][16],
                               int32_t i_qp );
+#define x264_quant_4x4_msa x264_template(quant_4x4_msa)
 int32_t x264_quant_4x4_msa( int16_t *p_dct, uint16_t *p_mf, uint16_t *p_bias );
+#define x264_quant_4x4x4_msa x264_template(quant_4x4x4_msa)
 int32_t x264_quant_4x4x4_msa( int16_t p_dct[4][16],
                               uint16_t pu_mf[16], uint16_t pu_bias[16] );
+#define x264_quant_8x8_msa x264_template(quant_8x8_msa)
 int32_t x264_quant_8x8_msa( int16_t *p_dct, uint16_t *p_mf, uint16_t *p_bias );
+#define x264_quant_4x4_dc_msa x264_template(quant_4x4_dc_msa)
 int32_t x264_quant_4x4_dc_msa( int16_t *p_dct, int32_t i_mf, int32_t i_bias );
+#define x264_coeff_last64_msa x264_template(coeff_last64_msa)
 int32_t x264_coeff_last64_msa( int16_t *p_src );
+#define x264_coeff_last16_msa x264_template(coeff_last16_msa)
 int32_t x264_coeff_last16_msa( int16_t *p_src );
 
 #endif
index 9b0da8b74c2d096592cebef602cdd914e5fb94b0..cc5fb990acbca1a2685279d05cd9521f98f167df 100644 (file)
@@ -793,12 +793,17 @@ typedef struct
 
 typedef struct x264_frame x264_frame;
 
+#define x264_opencl_load_library x264_template(opencl_load_library)
 x264_opencl_function_t *x264_opencl_load_library( void );
+#define x264_opencl_close_library x264_template(opencl_close_library)
 void x264_opencl_close_library( x264_opencl_function_t *ocl );
 
+#define x264_opencl_lookahead_init x264_template(opencl_lookahead_init)
 int x264_opencl_lookahead_init( x264_t *h );
+#define x264_opencl_lookahead_delete x264_template(opencl_lookahead_delete)
 void x264_opencl_lookahead_delete( x264_t *h );
 
+#define x264_opencl_frame_delete x264_template(opencl_frame_delete)
 void x264_opencl_frame_delete( x264_frame *frame );
 
 #endif
index 2b1fdd517ba52ea245e8fccd431f9d930c3fbf16..a8cf1d7cd1c50240d92755d806f6ea3740e2d5c7 100644 (file)
@@ -25,7 +25,7 @@
  * For more information, contact us at licensing@x264.com.
  *****************************************************************************/
 
-#include "common.h"
+#include "osdep.h"
 
 #ifdef _WIN32
 #include <windows.h>
index 7596e842d3ce34d7e6c4c57ec9001ef4cadb2946..75a474417403fd64857c07072fc8238ea8c52149 100644 (file)
@@ -103,6 +103,9 @@ int x264_is_pipe( const char *path );
 #define x264_is_pipe(x) 0
 #endif
 
+#define x264_glue3_expand(x,y,z) x##_##y##_##z
+#define x264_glue3(x,y,z) x264_glue3_expand(x,y,z)
+
 #ifdef _MSC_VER
 #define DECLARE_ALIGNED( var, n ) __declspec(align(n)) var
 #else
index d4dbfaf22a5f52864dde04c42837df7aa14e0ab6..7ff7b21b31dac51c3ecdccfe08c51b5c9e8ee94c 100644 (file)
@@ -143,13 +143,18 @@ typedef struct
     int (*intra_sad_x9_8x8)  ( pixel *fenc, pixel *fdec, pixel edge[36], uint16_t *bitcosts, uint16_t *satds );
 } x264_pixel_function_t;
 
+#define x264_pixel_init x264_template(pixel_init)
 void x264_pixel_init( int cpu, x264_pixel_function_t *pixf );
+#define x264_pixel_ssd_nv12 x264_template(pixel_ssd_nv12)
 void x264_pixel_ssd_nv12   ( x264_pixel_function_t *pf, pixel *pix1, intptr_t i_pix1, pixel *pix2, intptr_t i_pix2,
                              int i_width, int i_height, uint64_t *ssd_u, uint64_t *ssd_v );
+#define x264_pixel_ssd_wxh x264_template(pixel_ssd_wxh)
 uint64_t x264_pixel_ssd_wxh( x264_pixel_function_t *pf, pixel *pix1, intptr_t i_pix1, pixel *pix2, intptr_t i_pix2,
                              int i_width, int i_height );
+#define x264_pixel_ssim_wxh x264_template(pixel_ssim_wxh)
 float x264_pixel_ssim_wxh  ( x264_pixel_function_t *pf, pixel *pix1, intptr_t i_pix1, pixel *pix2, intptr_t i_pix2,
                              int i_width, int i_height, void *buf, int *cnt );
+#define x264_field_vsad x264_template(field_vsad)
 int x264_field_vsad( x264_t *h, int mb_x, int mb_y );
 
 #endif
index 2858bd0e823b66e578f3dd647665019b19d09d20..f237a7771ed8a7024384057989f526c4d9187a7f 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "common/common.h"
 #include "ppccommon.h"
+#include "dct.h"
 
 #if !HIGH_BIT_DEPTH
 #define VEC_DCT(a0,a1,a2,a3,b0,b1,b2,b3) \
index 89c43babe7d3fa25c4a0e46139ef92b03c07e88a..c8e9460c513df4a0f5ae3c5a7b6dd52bd90708b0 100644 (file)
 #ifndef X264_PPC_DCT_H
 #define X264_PPC_DCT_H
 
+#define x264_sub4x4_dct_altivec x264_template(sub4x4_dct_altivec)
 void x264_sub4x4_dct_altivec( int16_t dct[16], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub8x8_dct_altivec x264_template(sub8x8_dct_altivec)
 void x264_sub8x8_dct_altivec( int16_t dct[4][16], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub16x16_dct_altivec x264_template(sub16x16_dct_altivec)
 void x264_sub16x16_dct_altivec( int16_t dct[16][16], uint8_t *pix1, uint8_t *pix2 );
 
+#define x264_add8x8_idct_dc_altivec x264_template(add8x8_idct_dc_altivec)
 void x264_add8x8_idct_dc_altivec( uint8_t *p_dst, int16_t dct[4] );
 
+#define x264_add4x4_idct_altivec x264_template(add4x4_idct_altivec)
 void x264_add4x4_idct_altivec( uint8_t *p_dst, int16_t dct[16] );
+#define x264_add8x8_idct_altivec x264_template(add8x8_idct_altivec)
 void x264_add8x8_idct_altivec( uint8_t *p_dst, int16_t dct[4][16] );
+#define x264_add16x16_idct_altivec x264_template(add16x16_idct_altivec)
 void x264_add16x16_idct_altivec( uint8_t *p_dst, int16_t dct[16][16] );
 
+#define x264_sub8x8_dct_dc_altivec x264_template(sub8x8_dct_dc_altivec)
 void x264_sub8x8_dct_dc_altivec( int16_t dct[4], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub8x8_dct8_altivec x264_template(sub8x8_dct8_altivec)
 void x264_sub8x8_dct8_altivec( int16_t dct[64], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub16x16_dct8_altivec x264_template(sub16x16_dct8_altivec)
 void x264_sub16x16_dct8_altivec( int16_t dct[4][64], uint8_t *pix1, uint8_t *pix2 );
 
+#define x264_add8x8_idct8_altivec x264_template(add8x8_idct8_altivec)
 void x264_add8x8_idct8_altivec( uint8_t *dst, int16_t dct[64] );
+#define x264_add16x16_idct8_altivec x264_template(add16x16_idct8_altivec)
 void x264_add16x16_idct8_altivec( uint8_t *dst, int16_t dct[4][64] );
 
+#define x264_zigzag_scan_4x4_frame_altivec x264_template(zigzag_scan_4x4_frame_altivec)
 void x264_zigzag_scan_4x4_frame_altivec( int16_t level[16], int16_t dct[16] );
+#define x264_zigzag_scan_4x4_field_altivec x264_template(zigzag_scan_4x4_field_altivec)
 void x264_zigzag_scan_4x4_field_altivec( int16_t level[16], int16_t dct[16] );
+#define x264_zigzag_scan_8x8_frame_altivec x264_template(zigzag_scan_8x8_frame_altivec)
 void x264_zigzag_scan_8x8_frame_altivec( int16_t level[64], int16_t dct[64] );
+#define x264_zigzag_interleave_8x8_cavlc_altivec x264_template(zigzag_interleave_8x8_cavlc_altivec)
 void x264_zigzag_interleave_8x8_cavlc_altivec( int16_t *dst, int16_t *src, uint8_t *nnz );
 
 #endif
index 6a5b21ae95715a60e78d12eff35d607df8a712a0..3fc65aa1387b984b745ca00888dec4bbc0e05201 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "common/common.h"
 #include "ppccommon.h"
+#include "deblock.h"
 
 #if !HIGH_BIT_DEPTH
 #define transpose4x16(r0, r1, r2, r3)        \
diff --git a/common/ppc/deblock.h b/common/ppc/deblock.h
new file mode 100644 (file)
index 0000000..3d800cf
--- /dev/null
@@ -0,0 +1,34 @@
+/*****************************************************************************
+ * deblock.h: ppc deblocking
+ *****************************************************************************
+ * Copyright (C) 2017 x264 project
+ *
+ * Authors: Anton Mitrofanov <BugMaster@narod.ru>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@x264.com.
+ *****************************************************************************/
+
+#ifndef X264_PPC_DEBLOCK_H
+#define X264_PPC_DEBLOCK_H
+
+#define x264_deblock_v_luma_altivec x264_template(deblock_v_luma_altivec)
+void x264_deblock_v_luma_altivec( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_h_luma_altivec x264_template(deblock_h_luma_altivec)
+void x264_deblock_h_luma_altivec( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+
+#endif
index d1507548e645a6984e1b2ee99ccf24e2c78a346e..faf278162932df2452d82b93f6d01e4ea188d614 100644 (file)
@@ -25,8 +25,8 @@
  *****************************************************************************/
 
 #include "common/common.h"
-#include "mc.h"
 #include "ppccommon.h"
+#include "mc.h"
 
 #if !HIGH_BIT_DEPTH
 typedef void (*pf_mc_t)( uint8_t *src, intptr_t i_src,
@@ -140,6 +140,7 @@ static void mc_copy_w16_aligned_altivec( uint8_t *dst, intptr_t i_dst,
     }
 }
 
+#define x264_plane_copy_swap_core_altivec x264_template(plane_copy_swap_core_altivec)
 void x264_plane_copy_swap_core_altivec( uint8_t *dst, intptr_t i_dst,
                                         uint8_t *src, intptr_t i_src, int w, int h )
 {
@@ -155,6 +156,7 @@ void x264_plane_copy_swap_core_altivec( uint8_t *dst, intptr_t i_dst,
         }
 }
 
+#define x264_plane_copy_interleave_core_altivec x264_template(plane_copy_interleave_core_altivec)
 void x264_plane_copy_interleave_core_altivec( uint8_t *dst, intptr_t i_dst,
                                               uint8_t *srcu, intptr_t i_srcu,
                                               uint8_t *srcv, intptr_t i_srcv, int w, int h )
index f31bb39399f3d6cd9de312550c3751d384ddae63..3ee8086e08ca7acf31c6033e279e9fc1be5d4cec 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef X264_PPC_MC_H
 #define X264_PPC_MC_H
 
+#define x264_mc_init_altivec x264_template(mc_init_altivec)
 void x264_mc_init_altivec( x264_mc_functions_t *pf );
 
 #endif
index 9958e5fbe9ddd32cd3ef81554adc33c4083e2c82..0771eb8a15ebbafb9f092a19e9093369739186f7 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "common/common.h"
 #include "ppccommon.h"
+#include "pixel.h"
 
 #if !HIGH_BIT_DEPTH
 /***********************************************************************
index 84a497363b984c91b7323046d5373d2584685bd7..60a538c50885bcdda27504329245423d24d6f579 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef X264_PPC_PIXEL_H
 #define X264_PPC_PIXEL_H
 
+#define x264_pixel_init_altivec x264_template(pixel_init_altivec)
 void x264_pixel_init_altivec( x264_pixel_function_t *pixf );
 
 #endif
index 56d4be0183d43b7b9ae64c18ab224e754ec8f52a..4c7ad58ff16e58fc13720a1edf90bac8b22f2408 100644 (file)
@@ -24,9 +24,9 @@
  *****************************************************************************/
 
 #include "common/common.h"
+#include "ppccommon.h"
 #include "predict.h"
 #include "pixel.h"
-#include "ppccommon.h"
 
 #if !HIGH_BIT_DEPTH
 static void predict_8x8c_p_altivec( uint8_t *src )
index c81150a0fe5934247d57184560950d6530caaa59..bf73d6f69e12cd3c225560706a39baf5b72f1194 100644 (file)
@@ -26,7 +26,9 @@
 #ifndef X264_PPC_PREDICT_H
 #define X264_PPC_PREDICT_H
 
+#define x264_predict_16x16_init_altivec x264_template(predict_16x16_init_altivec)
 void x264_predict_16x16_init_altivec( x264_predict_t pf[7] );
+#define x264_predict_8x8c_init_altivec x264_template(predict_8x8c_init_altivec)
 void x264_predict_8x8c_init_altivec( x264_predict_t pf[7] );
 
 #endif /* X264_PPC_PREDICT_H */
index 7e607ca0a4e80b0245d0e7b23222f0b52446d158..b9de32614b77df7add9b9396babef0c32748b615 100644 (file)
 #ifndef X264_PPC_QUANT_H
 #define X264_PPC_QUANT_H
 
+#define x264_quant_4x4_altivec x264_template(quant_4x4_altivec)
 int x264_quant_4x4_altivec( int16_t dct[16], uint16_t mf[16], uint16_t bias[16] );
+#define x264_quant_8x8_altivec x264_template(quant_8x8_altivec)
 int x264_quant_8x8_altivec( int16_t dct[64], uint16_t mf[64], uint16_t bias[64] );
 
+#define x264_quant_4x4_dc_altivec x264_template(quant_4x4_dc_altivec)
 int x264_quant_4x4_dc_altivec( int16_t dct[16], int mf, int bias );
+#define x264_quant_2x2_dc_altivec x264_template(quant_2x2_dc_altivec)
 int x264_quant_2x2_dc_altivec( int16_t dct[4], int mf, int bias );
 
+#define x264_dequant_4x4_altivec x264_template(dequant_4x4_altivec)
 void x264_dequant_4x4_altivec( int16_t dct[16], int dequant_mf[6][16], int i_qp );
+#define x264_dequant_8x8_altivec x264_template(dequant_8x8_altivec)
 void x264_dequant_8x8_altivec( int16_t dct[64], int dequant_mf[6][64], int i_qp );
+
 #endif
index 9ec947633418fba77e5402f059f9ab082236001c..972c854c1ee890255fb4b7a0c07ed1ebdb0dafe3 100644 (file)
@@ -109,30 +109,52 @@ enum intra8x8_pred_e
     I_PRED_8x8_DC_128  = 11,
 };
 
+#define x264_predict_8x8_dc_c x264_template(predict_8x8_dc_c)
 void x264_predict_8x8_dc_c  ( pixel *src, pixel edge[36] );
+#define x264_predict_8x8_h_c x264_template(predict_8x8_h_c)
 void x264_predict_8x8_h_c   ( pixel *src, pixel edge[36] );
+#define x264_predict_8x8_v_c x264_template(predict_8x8_v_c)
 void x264_predict_8x8_v_c   ( pixel *src, pixel edge[36] );
+#define x264_predict_4x4_dc_c x264_template(predict_4x4_dc_c)
 void x264_predict_4x4_dc_c  ( pixel *src );
+#define x264_predict_4x4_h_c x264_template(predict_4x4_h_c)
 void x264_predict_4x4_h_c   ( pixel *src );
+#define x264_predict_4x4_v_c x264_template(predict_4x4_v_c)
 void x264_predict_4x4_v_c   ( pixel *src );
+#define x264_predict_16x16_dc_c x264_template(predict_16x16_dc_c)
 void x264_predict_16x16_dc_c( pixel *src );
+#define x264_predict_16x16_h_c x264_template(predict_16x16_h_c)
 void x264_predict_16x16_h_c ( pixel *src );
+#define x264_predict_16x16_v_c x264_template(predict_16x16_v_c)
 void x264_predict_16x16_v_c ( pixel *src );
+#define x264_predict_16x16_p_c x264_template(predict_16x16_p_c)
 void x264_predict_16x16_p_c ( pixel *src );
+#define x264_predict_8x8c_dc_c x264_template(predict_8x8c_dc_c)
 void x264_predict_8x8c_dc_c ( pixel *src );
+#define x264_predict_8x8c_h_c x264_template(predict_8x8c_h_c)
 void x264_predict_8x8c_h_c  ( pixel *src );
+#define x264_predict_8x8c_v_c x264_template(predict_8x8c_v_c)
 void x264_predict_8x8c_v_c  ( pixel *src );
+#define x264_predict_8x8c_p_c x264_template(predict_8x8c_p_c)
 void x264_predict_8x8c_p_c  ( pixel *src );
+#define x264_predict_8x16c_dc_c x264_template(predict_8x16c_dc_c)
 void x264_predict_8x16c_dc_c( pixel *src );
+#define x264_predict_8x16c_h_c x264_template(predict_8x16c_h_c)
 void x264_predict_8x16c_h_c ( pixel *src );
+#define x264_predict_8x16c_v_c x264_template(predict_8x16c_v_c)
 void x264_predict_8x16c_v_c ( pixel *src );
+#define x264_predict_8x16c_p_c x264_template(predict_8x16c_p_c)
 void x264_predict_8x16c_p_c ( pixel *src );
 
+#define x264_predict_16x16_init x264_template(predict_16x16_init)
 void x264_predict_16x16_init ( int cpu, x264_predict_t pf[7] );
+#define x264_predict_8x8c_init x264_template(predict_8x8c_init)
 void x264_predict_8x8c_init  ( int cpu, x264_predict_t pf[7] );
+#define x264_predict_8x16c_init x264_template(predict_8x16c_init)
 void x264_predict_8x16c_init ( int cpu, x264_predict_t pf[7] );
+#define x264_predict_4x4_init x264_template(predict_4x4_init)
 void x264_predict_4x4_init   ( int cpu, x264_predict_t pf[12] );
+#define x264_predict_8x8_init x264_template(predict_8x8_init)
 void x264_predict_8x8_init   ( int cpu, x264_predict8x8_t pf[12], x264_predict_8x8_filter_t *predict_filter );
 
-
 #endif
index b160cf5efde79686f4e3c1f3fff84a1123d3cd04..52dbf2b0a974f8364463d35312c762399b00adb7 100644 (file)
@@ -320,18 +320,6 @@ static void denoise_dct( dctcoef *dct, uint32_t *sum, udctcoef *offset, int size
  *  chroma: for the complete mb: if score < 7 -> null
  */
 
-const uint8_t x264_decimate_table4[16] =
-{
-    3,2,2,1,1,1,0,0,0,0,0,0,0,0,0,0
-};
-const uint8_t x264_decimate_table8[64] =
-{
-    3,3,3,3,2,2,2,2,2,2,2,2,1,1,1,1,
-    1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
-};
-
 static int ALWAYS_INLINE decimate_score_internal( dctcoef *dct, int i_max )
 {
     const uint8_t *ds_table = (i_max == 64) ? x264_decimate_table8 : x264_decimate_table4;
index 0bd0c21cd7a1124a9ef1ee55f9ac994b99d5f242..265ee615330d276e3cf1ff2cf52e9909510c62fd 100644 (file)
@@ -69,6 +69,7 @@ typedef struct
     int (*trellis_cabac_chroma_422_dc)( TRELLIS_PARAMS );
 } x264_quant_function_t;
 
+#define x264_quant_init x264_template(quant_init)
 void x264_quant_init( x264_t *h, int cpu, x264_quant_function_t *pf );
 
 #endif
index 2bd20281c06818acac4ca7cb42e12924d33c1b37..113a011e5b86955f64fea7623b3ed14bc7a949fa 100644 (file)
@@ -118,9 +118,12 @@ static ALWAYS_INLINE void x264_macroblock_cache_rect( void *dst, int w, int h, i
         assert(0);
 }
 
-extern void (*x264_cache_mv_func_table[10])(void *, uint32_t);\
-extern void (*x264_cache_mvd_func_table[10])(void *, uint32_t);\
-extern void (*x264_cache_ref_func_table[10])(void *, uint32_t);\
+#define x264_cache_mv_func_table x264_template(cache_mv_func_table)
+extern void (*x264_cache_mv_func_table[10])(void *, uint32_t);
+#define x264_cache_mvd_func_table x264_template(cache_mvd_func_table)
+extern void (*x264_cache_mvd_func_table[10])(void *, uint32_t);
+#define x264_cache_ref_func_table x264_template(cache_ref_func_table)
+extern void (*x264_cache_ref_func_table[10])(void *, uint32_t);
 
 #define x264_macroblock_cache_mv_ptr( a, x, y, w, h, l, mv ) x264_macroblock_cache_mv( a, x, y, w, h, l, M32( mv ) )
 static ALWAYS_INLINE void x264_macroblock_cache_mv( x264_t *h, int x, int y, int width, int height, int i_list, uint32_t mv )
index 5760f33c5abba3686f12e33bdc599cc92178345e..281628593da74e679bb758ebde2dff2b8a1bd826 100644 (file)
 #ifndef X264_SET_H
 #define X264_SET_H
 
-enum profile_e
-{
-    PROFILE_BASELINE = 66,
-    PROFILE_MAIN     = 77,
-    PROFILE_HIGH    = 100,
-    PROFILE_HIGH10  = 110,
-    PROFILE_HIGH422 = 122,
-    PROFILE_HIGH444_PREDICTIVE = 244,
-};
-
-enum chroma_format_e
-{
-    CHROMA_400 = 0,
-    CHROMA_420 = 1,
-    CHROMA_422 = 2,
-    CHROMA_444 = 3,
-};
-
 enum cqm4_e
 {
     CQM_4IY = 0,
@@ -192,156 +174,11 @@ typedef struct
 
 } x264_pps_t;
 
-/* default quant matrices */
-static const uint8_t x264_cqm_jvt4i[16] =
-{
-      6,13,20,28,
-     13,20,28,32,
-     20,28,32,37,
-     28,32,37,42
-};
-static const uint8_t x264_cqm_jvt4p[16] =
-{
-    10,14,20,24,
-    14,20,24,27,
-    20,24,27,30,
-    24,27,30,34
-};
-static const uint8_t x264_cqm_jvt8i[64] =
-{
-     6,10,13,16,18,23,25,27,
-    10,11,16,18,23,25,27,29,
-    13,16,18,23,25,27,29,31,
-    16,18,23,25,27,29,31,33,
-    18,23,25,27,29,31,33,36,
-    23,25,27,29,31,33,36,38,
-    25,27,29,31,33,36,38,40,
-    27,29,31,33,36,38,40,42
-};
-static const uint8_t x264_cqm_jvt8p[64] =
-{
-     9,13,15,17,19,21,22,24,
-    13,13,17,19,21,22,24,25,
-    15,17,19,21,22,24,25,27,
-    17,19,21,22,24,25,27,28,
-    19,21,22,24,25,27,28,30,
-    21,22,24,25,27,28,30,32,
-    22,24,25,27,28,30,32,33,
-    24,25,27,28,30,32,33,35
-};
-static const uint8_t x264_cqm_flat16[64] =
-{
-    16,16,16,16,16,16,16,16,
-    16,16,16,16,16,16,16,16,
-    16,16,16,16,16,16,16,16,
-    16,16,16,16,16,16,16,16,
-    16,16,16,16,16,16,16,16,
-    16,16,16,16,16,16,16,16,
-    16,16,16,16,16,16,16,16,
-    16,16,16,16,16,16,16,16
-};
-static const uint8_t * const x264_cqm_jvt[8] =
-{
-    x264_cqm_jvt4i, x264_cqm_jvt4p,
-    x264_cqm_jvt4i, x264_cqm_jvt4p,
-    x264_cqm_jvt8i, x264_cqm_jvt8p,
-    x264_cqm_jvt8i, x264_cqm_jvt8p
-};
-
-// 1080i25_avci50, 1080p25_avci50
-static const uint8_t x264_cqm_avci50_4ic[16] =
-{
-    16,22,28,40,
-    22,28,40,44,
-    28,40,44,48,
-    40,44,48,60
-};
-
-//  1080i25_avci50,
-static const uint8_t x264_cqm_avci50_1080i_8iy[64] =
-{
-    16,18,19,21,27,33,81,87,
-    18,19,21,24,30,33,81,87,
-    19,21,24,27,30,78,84,90,
-    21,24,27,30,33,78,84,90,
-    24,27,30,33,78,81,84,90,
-    24,27,30,33,78,81,84,93,
-    27,30,33,78,78,81,87,93,
-    30,33,33,78,81,84,87,96
-};
-
-//  1080p25_avci50, 720p25_avci50, 720p50_avci50
-static const uint8_t x264_cqm_avci50_p_8iy[64] =
-{
-    16,18,19,21,24,27,30,33,
-    18,19,21,24,27,30,33,78,
-    19,21,24,27,30,33,78,81,
-    21,24,27,30,33,78,81,84,
-    24,27,30,33,78,81,84,87,
-    27,30,33,78,81,84,87,90,
-    30,33,78,81,84,87,90,93,
-    33,78,81,84,87,90,93,96
-};
-
-//  1080i25_avci100, 1080p25_avci100
-static const uint8_t x264_cqm_avci100_1080_4ic[16] =
-{
-    16,20,26,32,
-    20,26,32,38,
-    26,32,38,44,
-    32,38,44,50
-};
-
-// 720p25_avci100, 720p50_avci100
-static const uint8_t x264_cqm_avci100_720p_4ic[16] =
-{
-    16,21,27,34,
-    21,27,34,41,
-    27,34,41,46,
-    34,41,46,54
-};
-
-//  1080i25_avci100,
-static const uint8_t x264_cqm_avci100_1080i_8iy[64] =
-{
-    16,19,20,23,24,26,32,42,
-    18,19,22,24,26,32,36,42,
-    18,20,23,24,26,32,36,63,
-    19,20,23,26,32,36,42,63,
-    20,22,24,26,32,36,59,63,
-    22,23,24,26,32,36,59,68,
-    22,23,24,26,32,42,59,68,
-    22,23,24,26,36,42,59,72
-};
-
-// 1080p25_avci100,
-static const uint8_t x264_cqm_avci100_1080p_8iy[64] =
-{
-    16,18,19,20,22,23,24,26,
-    18,19,20,22,23,24,26,32,
-    19,20,22,23,24,26,32,36,
-    20,22,23,24,26,32,36,42,
-    22,23,24,26,32,36,42,59,
-    23,24,26,32,36,42,59,63,
-    24,26,32,36,42,59,63,68,
-    26,32,36,42,59,63,68,72
-};
-
-// 720p25_avci100, 720p50_avci100
-static const uint8_t x264_cqm_avci100_720p_8iy[64] =
-{
-    16,18,19,21,22,24,26,32,
-    18,19,19,21,22,24,26,32,
-    19,19,21,22,22,24,26,32,
-    21,21,22,22,23,24,26,34,
-    22,22,22,23,24,25,26,34,
-    24,24,24,24,25,26,34,36,
-    26,26,26,26,26,34,36,38,
-    32,32,32,34,34,36,38,42
-};
-
+#define x264_cqm_init x264_template(cqm_init)
 int  x264_cqm_init( x264_t *h );
+#define x264_cqm_delete x264_template(cqm_delete)
 void x264_cqm_delete( x264_t *h );
+#define x264_cqm_parse_file x264_template(cqm_parse_file)
 int  x264_cqm_parse_file( x264_t *h, const char *filename );
 
 #endif
diff --git a/common/tables.c b/common/tables.c
new file mode 100644 (file)
index 0000000..79d9951
--- /dev/null
@@ -0,0 +1,2536 @@
+/*****************************************************************************
+ * tables.c: const tables
+ *****************************************************************************
+ * Copyright (C) 2003-2017 x264 project
+ *
+ * Authors: Laurent Aimar <fenrir@via.ecp.fr>
+ *          Loren Merritt <lorenm@u.washington.edu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@x264.com.
+ *****************************************************************************/
+
+#include "base.h"
+
+const x264_level_t x264_levels[] =
+{
+    { 10,     1485,     99,    396,     64,    175,   64, 64,  0, 2, 0, 0, 1 },
+    {  9,     1485,     99,    396,    128,    350,   64, 64,  0, 2, 0, 0, 1 }, /* "1b" */
+    { 11,     3000,    396,    900,    192,    500,  128, 64,  0, 2, 0, 0, 1 },
+    { 12,     6000,    396,   2376,    384,   1000,  128, 64,  0, 2, 0, 0, 1 },
+    { 13,    11880,    396,   2376,    768,   2000,  128, 64,  0, 2, 0, 0, 1 },
+    { 20,    11880,    396,   2376,   2000,   2000,  128, 64,  0, 2, 0, 0, 1 },
+    { 21,    19800,    792,   4752,   4000,   4000,  256, 64,  0, 2, 0, 0, 0 },
+    { 22,    20250,   1620,   8100,   4000,   4000,  256, 64,  0, 2, 0, 0, 0 },
+    { 30,    40500,   1620,   8100,  10000,  10000,  256, 32, 22, 2, 0, 1, 0 },
+    { 31,   108000,   3600,  18000,  14000,  14000,  512, 16, 60, 4, 1, 1, 0 },
+    { 32,   216000,   5120,  20480,  20000,  20000,  512, 16, 60, 4, 1, 1, 0 },
+    { 40,   245760,   8192,  32768,  20000,  25000,  512, 16, 60, 4, 1, 1, 0 },
+    { 41,   245760,   8192,  32768,  50000,  62500,  512, 16, 24, 2, 1, 1, 0 },
+    { 42,   522240,   8704,  34816,  50000,  62500,  512, 16, 24, 2, 1, 1, 1 },
+    { 50,   589824,  22080, 110400, 135000, 135000,  512, 16, 24, 2, 1, 1, 1 },
+    { 51,   983040,  36864, 184320, 240000, 240000,  512, 16, 24, 2, 1, 1, 1 },
+    { 52,  2073600,  36864, 184320, 240000, 240000,  512, 16, 24, 2, 1, 1, 1 },
+    { 60,  4177920, 139264, 696320, 240000, 240000, 8192, 16, 24, 2, 1, 1, 1 },
+    { 61,  8355840, 139264, 696320, 480000, 480000, 8192, 16, 24, 2, 1, 1, 1 },
+    { 62, 16711680, 139264, 696320, 800000, 800000, 8192, 16, 24, 2, 1, 1, 1 },
+    { 0 }
+};
+
+/*****************************************************************************
+ * MATH
+ *****************************************************************************/
+
+const uint8_t x264_exp2_lut[64] =
+{
+      0,   3,   6,   8,  11,  14,  17,  20,  23,  26,  29,  32,  36,  39,  42,  45,
+     48,  52,  55,  58,  62,  65,  69,  72,  76,  80,  83,  87,  91,  94,  98, 102,
+    106, 110, 114, 118, 122, 126, 130, 135, 139, 143, 147, 152, 156, 161, 165, 170,
+    175, 179, 184, 189, 194, 198, 203, 208, 214, 219, 224, 229, 234, 240, 245, 250
+};
+
+const float x264_log2_lut[128] =
+{
+    0.00000, 0.01123, 0.02237, 0.03342, 0.04439, 0.05528, 0.06609, 0.07682,
+    0.08746, 0.09803, 0.10852, 0.11894, 0.12928, 0.13955, 0.14975, 0.15987,
+    0.16993, 0.17991, 0.18982, 0.19967, 0.20945, 0.21917, 0.22882, 0.23840,
+    0.24793, 0.25739, 0.26679, 0.27612, 0.28540, 0.29462, 0.30378, 0.31288,
+    0.32193, 0.33092, 0.33985, 0.34873, 0.35755, 0.36632, 0.37504, 0.38370,
+    0.39232, 0.40088, 0.40939, 0.41785, 0.42626, 0.43463, 0.44294, 0.45121,
+    0.45943, 0.46761, 0.47573, 0.48382, 0.49185, 0.49985, 0.50779, 0.51570,
+    0.52356, 0.53138, 0.53916, 0.54689, 0.55459, 0.56224, 0.56986, 0.57743,
+    0.58496, 0.59246, 0.59991, 0.60733, 0.61471, 0.62205, 0.62936, 0.63662,
+    0.64386, 0.65105, 0.65821, 0.66534, 0.67243, 0.67948, 0.68650, 0.69349,
+    0.70044, 0.70736, 0.71425, 0.72110, 0.72792, 0.73471, 0.74147, 0.74819,
+    0.75489, 0.76155, 0.76818, 0.77479, 0.78136, 0.78790, 0.79442, 0.80090,
+    0.80735, 0.81378, 0.82018, 0.82655, 0.83289, 0.83920, 0.84549, 0.85175,
+    0.85798, 0.86419, 0.87036, 0.87652, 0.88264, 0.88874, 0.89482, 0.90087,
+    0.90689, 0.91289, 0.91886, 0.92481, 0.93074, 0.93664, 0.94251, 0.94837,
+    0.95420, 0.96000, 0.96578, 0.97154, 0.97728, 0.98299, 0.98868, 0.99435,
+};
+
+/* Avoid an int/float conversion. */
+const float x264_log2_lz_lut[32] =
+{
+    31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0
+};
+
+/*****************************************************************************
+ * ANALYSE
+ *****************************************************************************/
+
+/* lambda = pow(2,qp/6-2) */
+const uint16_t x264_lambda_tab[QP_MAX_MAX+1] =
+{
+   1,   1,   1,   1,   1,   1,   1,   1, /*  0- 7 */
+   1,   1,   1,   1,   1,   1,   1,   1, /*  8-15 */
+   2,   2,   2,   2,   3,   3,   3,   4, /* 16-23 */
+   4,   4,   5,   6,   6,   7,   8,   9, /* 24-31 */
+  10,  11,  13,  14,  16,  18,  20,  23, /* 32-39 */
+  25,  29,  32,  36,  40,  45,  51,  57, /* 40-47 */
+  64,  72,  81,  91, 102, 114, 128, 144, /* 48-55 */
+ 161, 181, 203, 228, 256, 287, 323, 362, /* 56-63 */
+ 406, 456, 512, 575, 645, 724, 813, 912, /* 64-71 */
+1024,1149,1290,1448,1625,1825,2048,2299, /* 72-79 */
+2580,2896,                               /* 80-81 */
+};
+
+/* lambda2 = pow(lambda,2) * .9 * 256 */
+/* Capped to avoid overflow */
+const int x264_lambda2_tab[QP_MAX_MAX+1] =
+{
+       14,       18,       22,       28,       36,       45,      57,      72, /*  0- 7 */
+       91,      115,      145,      182,      230,      290,     365,     460, /*  8-15 */
+      580,      731,      921,     1161,     1462,     1843,    2322,    2925, /* 16-23 */
+     3686,     4644,     5851,     7372,     9289,    11703,   14745,   18578, /* 24-31 */
+    23407,    29491,    37156,    46814,    58982,    74313,   93628,  117964, /* 32-39 */
+   148626,   187257,   235929,   297252,   374514,   471859,  594505,  749029, /* 40-47 */
+   943718,  1189010,  1498059,  1887436,  2378021,  2996119, 3774873, 4756042, /* 48-55 */
+  5992238,  7549747,  9512085, 11984476, 15099494, 19024170,23968953,30198988, /* 56-63 */
+ 38048341, 47937906, 60397977, 76096683, 95875813,120795955,                   /* 64-69 */
+134217727,134217727,134217727,134217727,134217727,134217727,                   /* 70-75 */
+134217727,134217727,134217727,134217727,134217727,134217727,                   /* 76-81 */
+};
+
+// should the intra and inter lambdas be different?
+// I'm just matching the behaviour of deadzone quant.
+const int x264_trellis_lambda2_tab[2][QP_MAX_MAX+1] =
+{
+    // inter lambda = .85 * .85 * 2**(qp/3. + 10 - LAMBDA_BITS)
+    {
+               46,       58,       73,       92,      117,      147,
+              185,      233,      294,      370,      466,      587,
+              740,      932,     1174,     1480,     1864,     2349,
+             2959,     3728,     4697,     5918,     7457,     9395,
+            11837,    14914,    18790,    23674,    29828,    37581,
+            47349,    59656,    75163,    94699,   119313,   150326,
+           189399,   238627,   300652,   378798,   477255,   601304,
+           757596,   954511,  1202608,  1515192,  1909022,  2405217,
+          3030384,  3818045,  4810435,  6060769,  7636091,  9620872,
+         12121539, 15272182, 19241743, 24243077, 30544363, 38483486,
+         48486154, 61088726, 76966972, 96972308,
+        122177453,134217727,134217727,134217727,134217727,134217727,
+        134217727,134217727,134217727,134217727,134217727,134217727,
+    },
+    // intra lambda = .65 * .65 * 2**(qp/3. + 10 - LAMBDA_BITS)
+    {
+               27,       34,       43,       54,       68,       86,
+              108,      136,      172,      216,      273,      343,
+              433,      545,      687,      865,     1090,     1374,
+             1731,     2180,     2747,     3461,     4361,     5494,
+             6922,     8721,    10988,    13844,    17442,    21976,
+            27688,    34885,    43953,    55377,    69771,    87906,
+           110755,   139543,   175813,   221511,   279087,   351627,
+           443023,   558174,   703255,   886046,  1116348,  1406511,
+          1772093,  2232697,  2813022,  3544186,  4465396,  5626046,
+          7088374,  8930791, 11252092, 14176748, 17861583, 22504184,
+         28353495, 35723165, 45008368, 56706990,
+         71446330, 90016736,113413980,134217727,134217727,134217727,
+        134217727,134217727,134217727,134217727,134217727,134217727,
+        134217727,134217727,134217727,134217727,134217727,134217727,
+    }
+};
+
+const uint16_t x264_chroma_lambda2_offset_tab[MAX_CHROMA_LAMBDA_OFFSET+1] =
+{
+       16,    20,    25,    32,    40,    50,
+       64,    80,   101,   128,   161,   203,
+      256,   322,   406,   512,   645,   812,
+     1024,  1290,  1625,  2048,  2580,  3250,
+     4096,  5160,  6501,  8192, 10321, 13003,
+    16384, 20642, 26007, 32768, 41285, 52015,
+    65535
+};
+
+/*****************************************************************************
+ * MC
+ *****************************************************************************/
+
+const uint8_t x264_hpel_ref0[16] = {0,1,1,1,0,1,1,1,2,3,3,3,0,1,1,1};
+const uint8_t x264_hpel_ref1[16] = {0,0,1,0,2,2,3,2,2,2,3,2,2,2,3,2};
+
+/*****************************************************************************
+ * CQM
+ *****************************************************************************/
+
+/* default quant matrices */
+const uint8_t x264_cqm_jvt4i[16] =
+{
+      6,13,20,28,
+     13,20,28,32,
+     20,28,32,37,
+     28,32,37,42
+};
+const uint8_t x264_cqm_jvt4p[16] =
+{
+    10,14,20,24,
+    14,20,24,27,
+    20,24,27,30,
+    24,27,30,34
+};
+const uint8_t x264_cqm_jvt8i[64] =
+{
+     6,10,13,16,18,23,25,27,
+    10,11,16,18,23,25,27,29,
+    13,16,18,23,25,27,29,31,
+    16,18,23,25,27,29,31,33,
+    18,23,25,27,29,31,33,36,
+    23,25,27,29,31,33,36,38,
+    25,27,29,31,33,36,38,40,
+    27,29,31,33,36,38,40,42
+};
+const uint8_t x264_cqm_jvt8p[64] =
+{
+     9,13,15,17,19,21,22,24,
+    13,13,17,19,21,22,24,25,
+    15,17,19,21,22,24,25,27,
+    17,19,21,22,24,25,27,28,
+    19,21,22,24,25,27,28,30,
+    21,22,24,25,27,28,30,32,
+    22,24,25,27,28,30,32,33,
+    24,25,27,28,30,32,33,35
+};
+const uint8_t x264_cqm_flat16[64] =
+{
+    16,16,16,16,16,16,16,16,
+    16,16,16,16,16,16,16,16,
+    16,16,16,16,16,16,16,16,
+    16,16,16,16,16,16,16,16,
+    16,16,16,16,16,16,16,16,
+    16,16,16,16,16,16,16,16,
+    16,16,16,16,16,16,16,16,
+    16,16,16,16,16,16,16,16
+};
+const uint8_t * const x264_cqm_jvt[8] =
+{
+    x264_cqm_jvt4i, x264_cqm_jvt4p,
+    x264_cqm_jvt4i, x264_cqm_jvt4p,
+    x264_cqm_jvt8i, x264_cqm_jvt8p,
+    x264_cqm_jvt8i, x264_cqm_jvt8p
+};
+
+// 1080i25_avci50, 1080p25_avci50
+const uint8_t x264_cqm_avci50_4ic[16] =
+{
+    16,22,28,40,
+    22,28,40,44,
+    28,40,44,48,
+    40,44,48,60
+};
+
+//  1080p25_avci50, 720p25_avci50, 720p50_avci50
+const uint8_t x264_cqm_avci50_p_8iy[64] =
+{
+    16,18,19,21,24,27,30,33,
+    18,19,21,24,27,30,33,78,
+    19,21,24,27,30,33,78,81,
+    21,24,27,30,33,78,81,84,
+    24,27,30,33,78,81,84,87,
+    27,30,33,78,81,84,87,90,
+    30,33,78,81,84,87,90,93,
+    33,78,81,84,87,90,93,96
+};
+
+//  1080i25_avci50,
+const uint8_t x264_cqm_avci50_1080i_8iy[64] =
+{
+    16,18,19,21,27,33,81,87,
+    18,19,21,24,30,33,81,87,
+    19,21,24,27,30,78,84,90,
+    21,24,27,30,33,78,84,90,
+    24,27,30,33,78,81,84,90,
+    24,27,30,33,78,81,84,93,
+    27,30,33,78,78,81,87,93,
+    30,33,33,78,81,84,87,96
+};
+
+// 720p25_avci100, 720p50_avci100
+const uint8_t x264_cqm_avci100_720p_4ic[16] =
+{
+    16,21,27,34,
+    21,27,34,41,
+    27,34,41,46,
+    34,41,46,54
+};
+
+// 720p25_avci100, 720p50_avci100
+const uint8_t x264_cqm_avci100_720p_8iy[64] =
+{
+    16,18,19,21,22,24,26,32,
+    18,19,19,21,22,24,26,32,
+    19,19,21,22,22,24,26,32,
+    21,21,22,22,23,24,26,34,
+    22,22,22,23,24,25,26,34,
+    24,24,24,24,25,26,34,36,
+    26,26,26,26,26,34,36,38,
+    32,32,32,34,34,36,38,42
+};
+
+//  1080i25_avci100, 1080p25_avci100
+const uint8_t x264_cqm_avci100_1080_4ic[16] =
+{
+    16,20,26,32,
+    20,26,32,38,
+    26,32,38,44,
+    32,38,44,50
+};
+
+//  1080i25_avci100,
+const uint8_t x264_cqm_avci100_1080i_8iy[64] =
+{
+    16,19,20,23,24,26,32,42,
+    18,19,22,24,26,32,36,42,
+    18,20,23,24,26,32,36,63,
+    19,20,23,26,32,36,42,63,
+    20,22,24,26,32,36,59,63,
+    22,23,24,26,32,36,59,68,
+    22,23,24,26,32,42,59,68,
+    22,23,24,26,36,42,59,72
+};
+
+// 1080p25_avci100,
+const uint8_t x264_cqm_avci100_1080p_8iy[64] =
+{
+    16,18,19,20,22,23,24,26,
+    18,19,20,22,23,24,26,32,
+    19,20,22,23,24,26,32,36,
+    20,22,23,24,26,32,36,42,
+    22,23,24,26,32,36,42,59,
+    23,24,26,32,36,42,59,63,
+    24,26,32,36,42,59,63,68,
+    26,32,36,42,59,63,68,72
+};
+
+/*****************************************************************************
+ * QUANT
+ *****************************************************************************/
+
+const uint8_t x264_decimate_table4[16] =
+{
+    3,2,2,1,1,1,0,0,0,0,0,0,0,0,0,0
+};
+const uint8_t x264_decimate_table8[64] =
+{
+    3,3,3,3,2,2,2,2,2,2,2,2,1,1,1,1,
+    1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+};
+
+/*****************************************************************************
+ * DCT
+ *****************************************************************************/
+
+/* the inverse of the scaling factors introduced by 8x8 fdct */
+/* uint32 is for the asm implementation of trellis. the actual values fit in uint16. */
+#define W(i) (i==0 ? FIX8(1.0000) :\
+              i==1 ? FIX8(0.8859) :\
+              i==2 ? FIX8(1.6000) :\
+              i==3 ? FIX8(0.9415) :\
+              i==4 ? FIX8(1.2651) :\
+              i==5 ? FIX8(1.1910) :0)
+const uint32_t x264_dct8_weight_tab[64] = {
+    W(0), W(3), W(4), W(3),  W(0), W(3), W(4), W(3),
+    W(3), W(1), W(5), W(1),  W(3), W(1), W(5), W(1),
+    W(4), W(5), W(2), W(5),  W(4), W(5), W(2), W(5),
+    W(3), W(1), W(5), W(1),  W(3), W(1), W(5), W(1),
+
+    W(0), W(3), W(4), W(3),  W(0), W(3), W(4), W(3),
+    W(3), W(1), W(5), W(1),  W(3), W(1), W(5), W(1),
+    W(4), W(5), W(2), W(5),  W(4), W(5), W(2), W(5),
+    W(3), W(1), W(5), W(1),  W(3), W(1), W(5), W(1)
+};
+#undef W
+
+#define W(i) (i==0 ? FIX8(1.76777) :\
+              i==1 ? FIX8(1.11803) :\
+              i==2 ? FIX8(0.70711) :0)
+const uint32_t x264_dct4_weight_tab[16] = {
+    W(0), W(1), W(0), W(1),
+    W(1), W(2), W(1), W(2),
+    W(0), W(1), W(0), W(1),
+    W(1), W(2), W(1), W(2)
+};
+#undef W
+
+/* inverse squared */
+#define W(i) (i==0 ? FIX8(3.125) :\
+              i==1 ? FIX8(1.25) :\
+              i==2 ? FIX8(0.5) :0)
+const uint32_t x264_dct4_weight2_tab[16] = {
+    W(0), W(1), W(0), W(1),
+    W(1), W(2), W(1), W(2),
+    W(0), W(1), W(0), W(1),
+    W(1), W(2), W(1), W(2)
+};
+#undef W
+
+#define W(i) (i==0 ? FIX8(1.00000) :\
+              i==1 ? FIX8(0.78487) :\
+              i==2 ? FIX8(2.56132) :\
+              i==3 ? FIX8(0.88637) :\
+              i==4 ? FIX8(1.60040) :\
+              i==5 ? FIX8(1.41850) :0)
+const uint32_t x264_dct8_weight2_tab[64] = {
+    W(0), W(3), W(4), W(3),  W(0), W(3), W(4), W(3),
+    W(3), W(1), W(5), W(1),  W(3), W(1), W(5), W(1),
+    W(4), W(5), W(2), W(5),  W(4), W(5), W(2), W(5),
+    W(3), W(1), W(5), W(1),  W(3), W(1), W(5), W(1),
+
+    W(0), W(3), W(4), W(3),  W(0), W(3), W(4), W(3),
+    W(3), W(1), W(5), W(1),  W(3), W(1), W(5), W(1),
+    W(4), W(5), W(2), W(5),  W(4), W(5), W(2), W(5),
+    W(3), W(1), W(5), W(1),  W(3), W(1), W(5), W(1)
+};
+#undef W
+
+/*****************************************************************************
+ * CABAC
+ *****************************************************************************/
+
+const int8_t x264_cabac_context_init_I[1024][2] =
+{
+    /* 0 - 10 */
+    { 20, -15 }, {  2, 54 },  {  3,  74 }, { 20, -15 },
+    {  2,  54 }, {  3, 74 },  { -28,127 }, { -23, 104 },
+    { -6,  53 }, { -1, 54 },  {  7,  51 },
+
+    /* 11 - 23 unused for I */
+    { 0, 0 },    { 0, 0 },    { 0, 0 },      { 0, 0 },
+    { 0, 0 },    { 0, 0 },    { 0, 0 },      { 0, 0 },
+    { 0, 0 },    { 0, 0 },    { 0, 0 },      { 0, 0 },
+    { 0, 0 },
+
+    /* 24- 39 */
+    { 0, 0 },    { 0, 0 },    { 0, 0 },      { 0, 0 },
+    { 0, 0 },    { 0, 0 },    { 0, 0 },      { 0, 0 },
+    { 0, 0 },    { 0, 0 },    { 0, 0 },      { 0, 0 },
+    { 0, 0 },    { 0, 0 },    { 0, 0 },      { 0, 0 },
+
+    /* 40 - 53 */
+    { 0, 0 },    { 0, 0 },    { 0, 0 },      { 0, 0 },
+    { 0, 0 },    { 0, 0 },    { 0, 0 },      { 0, 0 },
+    { 0, 0 },    { 0, 0 },    { 0, 0 },      { 0, 0 },
+    { 0, 0 },    { 0, 0 },
+
+    /* 54 - 59 */
+    { 0, 0 },    { 0, 0 },    { 0, 0 },      { 0, 0 },
+    { 0, 0 },    { 0, 0 },
+
+    /* 60 - 69 */
+    { 0, 41 },   { 0, 63 },   { 0, 63 },     { 0, 63 },
+    { -9, 83 },  { 4, 86 },   { 0, 97 },     { -7, 72 },
+    { 13, 41 },  { 3, 62 },
+
+    /* 70 -> 87 */
+    { 0, 11 },   { 1, 55 },   { 0, 69 },     { -17, 127 },
+    { -13, 102 },{ 0, 82 },   { -7, 74 },    { -21, 107 },
+    { -27, 127 },{ -31, 127 },{ -24, 127 },  { -18, 95 },
+    { -27, 127 },{ -21, 114 },{ -30, 127 },  { -17, 123 },
+    { -12, 115 },{ -16, 122 },
+
+    /* 88 -> 104 */
+    { -11, 115 },{ -12, 63 }, { -2, 68 },    { -15, 84 },
+    { -13, 104 },{ -3, 70 },  { -8, 93 },    { -10, 90 },
+    { -30, 127 },{ -1, 74 },  { -6, 97 },    { -7, 91 },
+    { -20, 127 },{ -4, 56 },  { -5, 82 },    { -7, 76 },
+    { -22, 125 },
+
+    /* 105 -> 135 */
+    { -7, 93 },  { -11, 87 }, { -3, 77 },    { -5, 71 },
+    { -4, 63 },  { -4, 68 },  { -12, 84 },   { -7, 62 },
+    { -7, 65 },  { 8, 61 },   { 5, 56 },     { -2, 66 },
+    { 1, 64 },   { 0, 61 },   { -2, 78 },    { 1, 50 },
+    { 7, 52 },   { 10, 35 },  { 0, 44 },     { 11, 38 },
+    { 1, 45 },   { 0, 46 },   { 5, 44 },     { 31, 17 },
+    { 1, 51 },   { 7, 50 },   { 28, 19 },    { 16, 33 },
+    { 14, 62 },  { -13, 108 },{ -15, 100 },
+
+    /* 136 -> 165 */
+    { -13, 101 },{ -13, 91 }, { -12, 94 },   { -10, 88 },
+    { -16, 84 }, { -10, 86 }, { -7, 83 },    { -13, 87 },
+    { -19, 94 }, { 1, 70 },   { 0, 72 },     { -5, 74 },
+    { 18, 59 },  { -8, 102 }, { -15, 100 },  { 0, 95 },
+    { -4, 75 },  { 2, 72 },   { -11, 75 },   { -3, 71 },
+    { 15, 46 },  { -13, 69 }, { 0, 62 },     { 0, 65 },
+    { 21, 37 },  { -15, 72 }, { 9, 57 },     { 16, 54 },
+    { 0, 62 },   { 12, 72 },
+
+    /* 166 -> 196 */
+    { 24, 0 },   { 15, 9 },   { 8, 25 },     { 13, 18 },
+    { 15, 9 },   { 13, 19 },  { 10, 37 },    { 12, 18 },
+    { 6, 29 },   { 20, 33 },  { 15, 30 },    { 4, 45 },
+    { 1, 58 },   { 0, 62 },   { 7, 61 },     { 12, 38 },
+    { 11, 45 },  { 15, 39 },  { 11, 42 },    { 13, 44 },
+    { 16, 45 },  { 12, 41 },  { 10, 49 },    { 30, 34 },
+    { 18, 42 },  { 10, 55 },  { 17, 51 },    { 17, 46 },
+    { 0, 89 },   { 26, -19 }, { 22, -17 },
+
+    /* 197 -> 226 */
+    { 26, -17 }, { 30, -25 }, { 28, -20 },   { 33, -23 },
+    { 37, -27 }, { 33, -23 }, { 40, -28 },   { 38, -17 },
+    { 33, -11 }, { 40, -15 }, { 41, -6 },    { 38, 1 },
+    { 41, 17 },  { 30, -6 },  { 27, 3 },     { 26, 22 },
+    { 37, -16 }, { 35, -4 },  { 38, -8 },    { 38, -3 },
+    { 37, 3 },   { 38, 5 },   { 42, 0 },     { 35, 16 },
+    { 39, 22 },  { 14, 48 },  { 27, 37 },    { 21, 60 },
+    { 12, 68 },  { 2, 97 },
+
+    /* 227 -> 251 */
+    { -3, 71 },  { -6, 42 },  { -5, 50 },    { -3, 54 },
+    { -2, 62 },  { 0, 58 },   { 1, 63 },     { -2, 72 },
+    { -1, 74 },  { -9, 91 },  { -5, 67 },    { -5, 27 },
+    { -3, 39 },  { -2, 44 },  { 0, 46 },     { -16, 64 },
+    { -8, 68 },  { -10, 78 }, { -6, 77 },    { -10, 86 },
+    { -12, 92 }, { -15, 55 }, { -10, 60 },   { -6, 62 },
+    { -4, 65 },
+
+    /* 252 -> 275 */
+    { -12, 73 }, { -8, 76 },  { -7, 80 },    { -9, 88 },
+    { -17, 110 },{ -11, 97 }, { -20, 84 },   { -11, 79 },
+    { -6, 73 },  { -4, 74 },  { -13, 86 },   { -13, 96 },
+    { -11, 97 }, { -19, 117 },{ -8, 78 },    { -5, 33 },
+    { -4, 48 },  { -2, 53 },  { -3, 62 },    { -13, 71 },
+    { -10, 79 }, { -12, 86 }, { -13, 90 },   { -14, 97 },
+
+    /* 276 a bit special (not used, x264_cabac_encode_bypass is used instead) */
+    { 0, 0 },
+
+    /* 277 -> 307 */
+    { -6, 93 },  { -6, 84 },  { -8, 79 },    { 0, 66 },
+    { -1, 71 },  { 0, 62 },   { -2, 60 },    { -2, 59 },
+    { -5, 75 },  { -3, 62 },  { -4, 58 },    { -9, 66 },
+    { -1, 79 },  { 0, 71 },   { 3, 68 },     { 10, 44 },
+    { -7, 62 },  { 15, 36 },  { 14, 40 },    { 16, 27 },
+    { 12, 29 },  { 1, 44 },   { 20, 36 },    { 18, 32 },
+    { 5, 42 },   { 1, 48 },   { 10, 62 },    { 17, 46 },
+    { 9, 64 },   { -12, 104 },{ -11, 97 },
+
+    /* 308 -> 337 */
+    { -16, 96 }, { -7, 88 },  { -8, 85 },    { -7, 85 },
+    { -9, 85 },  { -13, 88 }, { 4, 66 },     { -3, 77 },
+    { -3, 76 },  { -6, 76 },  { 10, 58 },    { -1, 76 },
+    { -1, 83 },  { -7, 99 },  { -14, 95 },   { 2, 95 },
+    { 0, 76 },   { -5, 74 },  { 0, 70 },     { -11, 75 },
+    { 1, 68 },   { 0, 65 },   { -14, 73 },   { 3, 62 },
+    { 4, 62 },   { -1, 68 },  { -13, 75 },   { 11, 55 },
+    { 5, 64 },   { 12, 70 },
+
+    /* 338 -> 368 */
+    { 15, 6 },   { 6, 19 },   { 7, 16 },     { 12, 14 },
+    { 18, 13 },  { 13, 11 },  { 13, 15 },    { 15, 16 },
+    { 12, 23 },  { 13, 23 },  { 15, 20 },    { 14, 26 },
+    { 14, 44 },  { 17, 40 },  { 17, 47 },    { 24, 17 },
+    { 21, 21 },  { 25, 22 },  { 31, 27 },    { 22, 29 },
+    { 19, 35 },  { 14, 50 },  { 10, 57 },    { 7, 63 },
+    { -2, 77 },  { -4, 82 },  { -3, 94 },    { 9, 69 },
+    { -12, 109 },{ 36, -35 }, { 36, -34 },
+
+    /* 369 -> 398 */
+    { 32, -26 }, { 37, -30 }, { 44, -32 },   { 34, -18 },
+    { 34, -15 }, { 40, -15 }, { 33, -7 },    { 35, -5 },
+    { 33, 0 },   { 38, 2 },   { 33, 13 },    { 23, 35 },
+    { 13, 58 },  { 29, -3 },  { 26, 0 },     { 22, 30 },
+    { 31, -7 },  { 35, -15 }, { 34, -3 },    { 34, 3 },
+    { 36, -1 },  { 34, 5 },   { 32, 11 },    { 35, 5 },
+    { 34, 12 },  { 39, 11 },  { 30, 29 },    { 34, 26 },
+    { 29, 39 },  { 19, 66 },
+
+    /* 399 -> 435 */
+    {  31,  21 }, {  31,  31 }, {  25,  50 },
+    { -17, 120 }, { -20, 112 }, { -18, 114 }, { -11,  85 },
+    { -15,  92 }, { -14,  89 }, { -26,  71 }, { -15,  81 },
+    { -14,  80 }, {   0,  68 }, { -14,  70 }, { -24,  56 },
+    { -23,  68 }, { -24,  50 }, { -11,  74 }, {  23, -13 },
+    {  26, -13 }, {  40, -15 }, {  49, -14 }, {  44,   3 },
+    {  45,   6 }, {  44,  34 }, {  33,  54 }, {  19,  82 },
+    {  -3,  75 }, {  -1,  23 }, {   1,  34 }, {   1,  43 },
+    {   0,  54 }, {  -2,  55 }, {   0,  61 }, {   1,  64 },
+    {   0,  68 }, {  -9,  92 },
+
+    /* 436 -> 459 */
+    { -14, 106 }, { -13,  97 }, { -15,  90 }, { -12,  90 },
+    { -18,  88 }, { -10,  73 }, {  -9,  79 }, { -14,  86 },
+    { -10,  73 }, { -10,  70 }, { -10,  69 }, {  -5,  66 },
+    {  -9,  64 }, {  -5,  58 }, {   2,  59 }, {  21, -10 },
+    {  24, -11 }, {  28,  -8 }, {  28,  -1 }, {  29,   3 },
+    {  29,   9 }, {  35,  20 }, {  29,  36 }, {  14,  67 },
+
+    /* 460 -> 1024 */
+    { -17, 123 }, { -12, 115 }, { -16, 122 }, { -11, 115 },
+    { -12,  63 }, {  -2,  68 }, { -15,  84 }, { -13, 104 },
+    {  -3,  70 }, {  -8,  93 }, { -10,  90 }, { -30, 127 },
+    { -17, 123 }, { -12, 115 }, { -16, 122 }, { -11, 115 },
+    { -12,  63 }, {  -2,  68 }, { -15,  84 }, { -13, 104 },
+    {  -3,  70 }, {  -8,  93 }, { -10,  90 }, { -30, 127 },
+    {  -7,  93 }, { -11,  87 }, {  -3,  77 }, {  -5,  71 },
+    {  -4,  63 }, {  -4,  68 }, { -12,  84 }, {  -7,  62 },
+    {  -7,  65 }, {   8,  61 }, {   5,  56 }, {  -2,  66 },
+    {   1,  64 }, {   0,  61 }, {  -2,  78 }, {   1,  50 },
+    {   7,  52 }, {  10,  35 }, {   0,  44 }, {  11,  38 },
+    {   1,  45 }, {   0,  46 }, {   5,  44 }, {  31,  17 },
+    {   1,  51 }, {   7,  50 }, {  28,  19 }, {  16,  33 },
+    {  14,  62 }, { -13, 108 }, { -15, 100 }, { -13, 101 },
+    { -13,  91 }, { -12,  94 }, { -10,  88 }, { -16,  84 },
+    { -10,  86 }, {  -7,  83 }, { -13,  87 }, { -19,  94 },
+    {   1,  70 }, {   0,  72 }, {  -5,  74 }, {  18,  59 },
+    {  -7,  93 }, { -11,  87 }, {  -3,  77 }, {  -5,  71 },
+    {  -4,  63 }, {  -4,  68 }, { -12,  84 }, {  -7,  62 },
+    {  -7,  65 }, {   8,  61 }, {   5,  56 }, {  -2,  66 },
+    {   1,  64 }, {   0,  61 }, {  -2,  78 }, {   1,  50 },
+    {   7,  52 }, {  10,  35 }, {   0,  44 }, {  11,  38 },
+    {   1,  45 }, {   0,  46 }, {   5,  44 }, {  31,  17 },
+    {   1,  51 }, {   7,  50 }, {  28,  19 }, {  16,  33 },
+    {  14,  62 }, { -13, 108 }, { -15, 100 }, { -13, 101 },
+    { -13,  91 }, { -12,  94 }, { -10,  88 }, { -16,  84 },
+    { -10,  86 }, {  -7,  83 }, { -13,  87 }, { -19,  94 },
+    {   1,  70 }, {   0,  72 }, {  -5,  74 }, {  18,  59 },
+    {  24,   0 }, {  15,   9 }, {   8,  25 }, {  13,  18 },
+    {  15,   9 }, {  13,  19 }, {  10,  37 }, {  12,  18 },
+    {   6,  29 }, {  20,  33 }, {  15,  30 }, {   4,  45 },
+    {   1,  58 }, {   0,  62 }, {   7,  61 }, {  12,  38 },
+    {  11,  45 }, {  15,  39 }, {  11,  42 }, {  13,  44 },
+    {  16,  45 }, {  12,  41 }, {  10,  49 }, {  30,  34 },
+    {  18,  42 }, {  10,  55 }, {  17,  51 }, {  17,  46 },
+    {   0,  89 }, {  26, -19 }, {  22, -17 }, {  26, -17 },
+    {  30, -25 }, {  28, -20 }, {  33, -23 }, {  37, -27 },
+    {  33, -23 }, {  40, -28 }, {  38, -17 }, {  33, -11 },
+    {  40, -15 }, {  41,  -6 }, {  38,   1 }, {  41,  17 },
+    {  24,   0 }, {  15,   9 }, {   8,  25 }, {  13,  18 },
+    {  15,   9 }, {  13,  19 }, {  10,  37 }, {  12,  18 },
+    {   6,  29 }, {  20,  33 }, {  15,  30 }, {   4,  45 },
+    {   1,  58 }, {   0,  62 }, {   7,  61 }, {  12,  38 },
+    {  11,  45 }, {  15,  39 }, {  11,  42 }, {  13,  44 },
+    {  16,  45 }, {  12,  41 }, {  10,  49 }, {  30,  34 },
+    {  18,  42 }, {  10,  55 }, {  17,  51 }, {  17,  46 },
+    {   0,  89 }, {  26, -19 }, {  22, -17 }, {  26, -17 },
+    {  30, -25 }, {  28, -20 }, {  33, -23 }, {  37, -27 },
+    {  33, -23 }, {  40, -28 }, {  38, -17 }, {  33, -11 },
+    {  40, -15 }, {  41,  -6 }, {  38,   1 }, {  41,  17 },
+    { -17, 120 }, { -20, 112 }, { -18, 114 }, { -11,  85 },
+    { -15,  92 }, { -14,  89 }, { -26,  71 }, { -15,  81 },
+    { -14,  80 }, {   0,  68 }, { -14,  70 }, { -24,  56 },
+    { -23,  68 }, { -24,  50 }, { -11,  74 }, { -14, 106 },
+    { -13,  97 }, { -15,  90 }, { -12,  90 }, { -18,  88 },
+    { -10,  73 }, {  -9,  79 }, { -14,  86 }, { -10,  73 },
+    { -10,  70 }, { -10,  69 }, {  -5,  66 }, {  -9,  64 },
+    {  -5,  58 }, {   2,  59 }, {  23, -13 }, {  26, -13 },
+    {  40, -15 }, {  49, -14 }, {  44,   3 }, {  45,   6 },
+    {  44,  34 }, {  33,  54 }, {  19,  82 }, {  21, -10 },
+    {  24, -11 }, {  28,  -8 }, {  28,  -1 }, {  29,   3 },
+    {  29,   9 }, {  35,  20 }, {  29,  36 }, {  14,  67 },
+    {  -3,  75 }, {  -1,  23 }, {   1,  34 }, {   1,  43 },
+    {   0,  54 }, {  -2,  55 }, {   0,  61 }, {   1,  64 },
+    {   0,  68 }, {  -9,  92 }, { -17, 120 }, { -20, 112 },
+    { -18, 114 }, { -11,  85 }, { -15,  92 }, { -14,  89 },
+    { -26,  71 }, { -15,  81 }, { -14,  80 }, {   0,  68 },
+    { -14,  70 }, { -24,  56 }, { -23,  68 }, { -24,  50 },
+    { -11,  74 }, { -14, 106 }, { -13,  97 }, { -15,  90 },
+    { -12,  90 }, { -18,  88 }, { -10,  73 }, {  -9,  79 },
+    { -14,  86 }, { -10,  73 }, { -10,  70 }, { -10,  69 },
+    {  -5,  66 }, {  -9,  64 }, {  -5,  58 }, {   2,  59 },
+    {  23, -13 }, {  26, -13 }, {  40, -15 }, {  49, -14 },
+    {  44,   3 }, {  45,   6 }, {  44,  34 }, {  33,  54 },
+    {  19,  82 }, {  21, -10 }, {  24, -11 }, {  28,  -8 },
+    {  28,  -1 }, {  29,   3 }, {  29,   9 }, {  35,  20 },
+    {  29,  36 }, {  14,  67 }, {  -3,  75 }, {  -1,  23 },
+    {   1,  34 }, {   1,  43 }, {   0,  54 }, {  -2,  55 },
+    {   0,  61 }, {   1,  64 }, {   0,  68 }, {  -9,  92 },
+    {  -6,  93 }, {  -6,  84 }, {  -8,  79 }, {   0,  66 },
+    {  -1,  71 }, {   0,  62 }, {  -2,  60 }, {  -2,  59 },
+    {  -5,  75 }, {  -3,  62 }, {  -4,  58 }, {  -9,  66 },
+    {  -1,  79 }, {   0,  71 }, {   3,  68 }, {  10,  44 },
+    {  -7,  62 }, {  15,  36 }, {  14,  40 }, {  16,  27 },
+    {  12,  29 }, {   1,  44 }, {  20,  36 }, {  18,  32 },
+    {   5,  42 }, {   1,  48 }, {  10,  62 }, {  17,  46 },
+    {   9,  64 }, { -12, 104 }, { -11,  97 }, { -16,  96 },
+    {  -7,  88 }, {  -8,  85 }, {  -7,  85 }, {  -9,  85 },
+    { -13,  88 }, {   4,  66 }, {  -3,  77 }, {  -3,  76 },
+    {  -6,  76 }, {  10,  58 }, {  -1,  76 }, {  -1,  83 },
+    {  -6,  93 }, {  -6,  84 }, {  -8,  79 }, {   0,  66 },
+    {  -1,  71 }, {   0,  62 }, {  -2,  60 }, {  -2,  59 },
+    {  -5,  75 }, {  -3,  62 }, {  -4,  58 }, {  -9,  66 },
+    {  -1,  79 }, {   0,  71 }, {   3,  68 }, {  10,  44 },
+    {  -7,  62 }, {  15,  36 }, {  14,  40 }, {  16,  27 },
+    {  12,  29 }, {   1,  44 }, {  20,  36 }, {  18,  32 },
+    {   5,  42 }, {   1,  48 }, {  10,  62 }, {  17,  46 },
+    {   9,  64 }, { -12, 104 }, { -11,  97 }, { -16,  96 },
+    {  -7,  88 }, {  -8,  85 }, {  -7,  85 }, {  -9,  85 },
+    { -13,  88 }, {   4,  66 }, {  -3,  77 }, {  -3,  76 },
+    {  -6,  76 }, {  10,  58 }, {  -1,  76 }, {  -1,  83 },
+    {  15,   6 }, {   6,  19 }, {   7,  16 }, {  12,  14 },
+    {  18,  13 }, {  13,  11 }, {  13,  15 }, {  15,  16 },
+    {  12,  23 }, {  13,  23 }, {  15,  20 }, {  14,  26 },
+    {  14,  44 }, {  17,  40 }, {  17,  47 }, {  24,  17 },
+    {  21,  21 }, {  25,  22 }, {  31,  27 }, {  22,  29 },
+    {  19,  35 }, {  14,  50 }, {  10,  57 }, {   7,  63 },
+    {  -2,  77 }, {  -4,  82 }, {  -3,  94 }, {   9,  69 },
+    { -12, 109 }, {  36, -35 }, {  36, -34 }, {  32, -26 },
+    {  37, -30 }, {  44, -32 }, {  34, -18 }, {  34, -15 },
+    {  40, -15 }, {  33,  -7 }, {  35,  -5 }, {  33,   0 },
+    {  38,   2 }, {  33,  13 }, {  23,  35 }, {  13,  58 },
+    {  15,   6 }, {   6,  19 }, {   7,  16 }, {  12,  14 },
+    {  18,  13 }, {  13,  11 }, {  13,  15 }, {  15,  16 },
+    {  12,  23 }, {  13,  23 }, {  15,  20 }, {  14,  26 },
+    {  14,  44 }, {  17,  40 }, {  17,  47 }, {  24,  17 },
+    {  21,  21 }, {  25,  22 }, {  31,  27 }, {  22,  29 },
+    {  19,  35 }, {  14,  50 }, {  10,  57 }, {   7,  63 },
+    {  -2,  77 }, {  -4,  82 }, {  -3,  94 }, {   9,  69 },
+    { -12, 109 }, {  36, -35 }, {  36, -34 }, {  32, -26 },
+    {  37, -30 }, {  44, -32 }, {  34, -18 }, {  34, -15 },
+    {  40, -15 }, {  33,  -7 }, {  35,  -5 }, {  33,   0 },
+    {  38,   2 }, {  33,  13 }, {  23,  35 }, {  13,  58 },
+    {  -3,  71 }, {  -6,  42 }, {  -5,  50 }, {  -3,  54 },
+    {  -2,  62 }, {   0,  58 }, {   1,  63 }, {  -2,  72 },
+    {  -1,  74 }, {  -9,  91 }, {  -5,  67 }, {  -5,  27 },
+    {  -3,  39 }, {  -2,  44 }, {   0,  46 }, { -16,  64 },
+    {  -8,  68 }, { -10,  78 }, {  -6,  77 }, { -10,  86 },
+    { -12,  92 }, { -15,  55 }, { -10,  60 }, {  -6,  62 },
+    {  -4,  65 }, { -12,  73 }, {  -8,  76 }, {  -7,  80 },
+    {  -9,  88 }, { -17, 110 }, {  -3,  71 }, {  -6,  42 },
+    {  -5,  50 }, {  -3,  54 }, {  -2,  62 }, {   0,  58 },
+    {   1,  63 }, {  -2,  72 }, {  -1,  74 }, {  -9,  91 },
+    {  -5,  67 }, {  -5,  27 }, {  -3,  39 }, {  -2,  44 },
+    {   0,  46 }, { -16,  64 }, {  -8,  68 }, { -10,  78 },
+    {  -6,  77 }, { -10,  86 }, { -12,  92 }, { -15,  55 },
+    { -10,  60 }, {  -6,  62 }, {  -4,  65 }, { -12,  73 },
+    {  -8,  76 }, {  -7,  80 }, {  -9,  88 }, { -17, 110 },
+    {  -3,  70 }, {  -8,  93 }, { -10,  90 }, { -30, 127 },
+    {  -3,  70 }, {  -8,  93 }, { -10,  90 }, { -30, 127 },
+    {  -3,  70 }, {  -8,  93 }, { -10,  90 }, { -30, 127 }
+};
+
+const int8_t x264_cabac_context_init_PB[3][1024][2] =
+{
+    /* i_cabac_init_idc == 0 */
+    {
+        /* 0 - 10 */
+        {  20, -15 }, {   2,  54 }, {   3,  74 }, {  20, -15 },
+        {   2,  54 }, {   3,  74 }, { -28, 127 }, { -23, 104 },
+        {  -6,  53 }, {  -1,  54 }, {   7,  51 },
+
+        /* 11 - 23 */
+        {  23,  33 }, {  23,   2 }, {  21,   0 }, {   1,   9 },
+        {   0,  49 }, { -37, 118 }, {   5,  57 }, { -13,  78 },
+        { -11,  65 }, {   1,  62 }, {  12,  49 }, {  -4,  73 },
+        {  17,  50 },
+
+        /* 24 - 39 */
+        {  18,  64 }, {   9,  43 }, {  29,   0 }, {  26,  67 },
+        {  16,  90 }, {   9, 104 }, { -46, 127 }, { -20, 104 },
+        {   1,  67 }, { -13,  78 }, { -11,  65 }, {   1,  62 },
+        {  -6,  86 }, { -17,  95 }, {  -6,  61 }, {   9,  45 },
+
+        /* 40 - 53 */
+        {  -3,  69 }, {  -6,  81 }, { -11,  96 }, {   6,  55 },
+        {   7,  67 }, {  -5,  86 }, {   2,  88 }, {   0,  58 },
+        {  -3,  76 }, { -10,  94 }, {   5,  54 }, {   4,  69 },
+        {  -3,  81 }, {   0,  88 },
+
+        /* 54 - 59 */
+        {  -7,  67 }, {  -5,  74 }, {  -4,  74 }, {  -5,  80 },
+        {  -7,  72 }, {   1,  58 },
+
+        /* 60 - 69 */
+        {   0,  41 }, {   0,  63 }, {   0,  63 }, { 0, 63 },
+        {  -9,  83 }, {   4,  86 }, {   0,  97 }, { -7, 72 },
+        {  13,  41 }, {   3,  62 },
+
+        /* 70 - 87 */
+        {   0,  45 }, {  -4,  78 }, {  -3,  96 }, { -27,  126 },
+        { -28,  98 }, { -25, 101 }, { -23,  67 }, { -28,  82 },
+        { -20,  94 }, { -16,  83 }, { -22, 110 }, { -21,  91 },
+        { -18, 102 }, { -13,  93 }, { -29, 127 }, {  -7,  92 },
+        {  -5,  89 }, {  -7,  96 }, { -13, 108 }, {  -3,  46 },
+        {  -1,  65 }, {  -1,  57 }, {  -9,  93 }, {  -3,  74 },
+        {  -9,  92 }, {  -8,  87 }, { -23, 126 }, {   5,  54 },
+        {   6,  60 }, {   6,  59 }, {   6,  69 }, {  -1,  48 },
+        {   0,  68 }, {  -4,  69 }, {  -8,  88 },
+
+        /* 105 -> 165 */
+        {  -2,  85 }, {  -6,  78 }, {  -1,  75 }, {  -7,  77 },
+        {   2,  54 }, {   5,  50 }, {  -3,  68 }, {   1,  50 },
+        {   6,  42 }, {  -4,  81 }, {   1,  63 }, {  -4,  70 },
+        {   0,  67 }, {   2,  57 }, {  -2,  76 }, {  11,  35 },
+        {   4,  64 }, {   1,  61 }, {  11,  35 }, {  18,  25 },
+        {  12,  24 }, {  13,  29 }, {  13,  36 }, { -10,  93 },
+        {  -7,  73 }, {  -2,  73 }, {  13,  46 }, {   9,  49 },
+        {  -7, 100 }, {   9,  53 }, {   2,  53 }, {   5,  53 },
+        {  -2,  61 }, {   0,  56 }, {   0,  56 }, { -13,  63 },
+        {  -5,  60 }, {  -1,  62 }, {   4,  57 }, {  -6,  69 },
+        {   4,  57 }, {  14,  39 }, {   4,  51 }, {  13,  68 },
+        {   3,  64 }, {   1,  61 }, {   9,  63 }, {   7,  50 },
+        {  16,  39 }, {   5,  44 }, {   4,  52 }, {  11,  48 },
+        {  -5,  60 }, {  -1,  59 }, {   0,  59 }, {  22,  33 },
+        {   5,  44 }, {  14,  43 }, {  -1,  78 }, {   0,  60 },
+        {   9,  69 },
+
+        /* 166 - 226 */
+        {  11,  28 }, {   2,  40 }, {   3,  44 }, {   0,  49 },
+        {   0,  46 }, {   2,  44 }, {   2,  51 }, {   0,  47 },
+        {   4,  39 }, {   2,  62 }, {   6,  46 }, {   0,  54 },
+        {   3,  54 }, {   2,  58 }, {   4,  63 }, {   6,  51 },
+        {   6,  57 }, {   7,  53 }, {   6,  52 }, {   6,  55 },
+        {  11,  45 }, {  14,  36 }, {   8,  53 }, {  -1,  82 },
+        {   7,  55 }, {  -3,  78 }, {  15,  46 }, {  22,  31 },
+        {  -1,  84 }, {  25,   7 }, {  30,  -7 }, {  28,   3 },
+        {  28,   4 }, {  32,   0 }, {  34,  -1 }, {  30,   6 },
+        {  30,   6 }, {  32,   9 }, {  31,  19 }, {  26,  27 },
+        {  26,  30 }, {  37,  20 }, {  28,  34 }, {  17,  70 },
+        {   1,  67 }, {   5,  59 }, {   9,  67 }, {  16,  30 },
+        {  18,  32 }, {  18,  35 }, {  22,  29 }, {  24,  31 },
+        {  23,  38 }, {  18,  43 }, {  20,  41 }, {  11,  63 },
+        {   9,  59 }, {   9,  64 }, {  -1,  94 }, {  -2,  89 },
+        {  -9, 108 },
+
+        /* 227 - 275 */
+        {  -6,  76 }, {  -2,  44 }, {   0,  45 }, {   0,  52 },
+        {  -3,  64 }, {  -2,  59 }, {  -4,  70 }, {  -4,  75 },
+        {  -8,  82 }, { -17, 102 }, {  -9,  77 }, {   3,  24 },
+        {   0,  42 }, {   0,  48 }, {   0,  55 }, {  -6,  59 },
+        {  -7,  71 }, { -12,  83 }, { -11,  87 }, { -30, 119 },
+        {   1,  58 }, {  -3,  29 }, {  -1,  36 }, {   1,  38 },
+        {   2,  43 }, {  -6,  55 }, {   0,  58 }, {   0,  64 },
+        {  -3,  74 }, { -10,  90 }, {   0,  70 }, {  -4,  29 },
+        {   5,  31 }, {   7,  42 }, {   1,  59 }, {  -2,  58 },
+        {  -3,  72 }, {  -3,  81 }, { -11,  97 }, {   0,  58 },
+        {   8,   5 }, {  10,  14 }, {  14,  18 }, {  13,  27 },
+        {   2,  40 }, {   0,  58 }, {  -3,  70 }, {  -6,  79 },
+        {  -8,  85 },
+
+        /* 276 a bit special (not used, x264_cabac_encode_bypass is used instead) */
+        { 0, 0 },
+
+        /* 277 - 337 */
+        { -13, 106 }, { -16, 106 }, { -10,  87 }, { -21, 114 },
+        { -18, 110 }, { -14,  98 }, { -22, 110 }, { -21, 106 },
+        { -18, 103 }, { -21, 107 }, { -23, 108 }, { -26, 112 },
+        { -10,  96 }, { -12,  95 }, {  -5,  91 }, {  -9,  93 },
+        { -22,  94 }, {  -5,  86 }, {   9,  67 }, {  -4,  80 },
+        { -10,  85 }, {  -1,  70 }, {   7,  60 }, {   9,  58 },
+        {   5,  61 }, {  12,  50 }, {  15,  50 }, {  18,  49 },
+        {  17,  54 }, {  10,  41 }, {   7,  46 }, {  -1,  51 },
+        {   7,  49 }, {   8,  52 }, {   9,  41 }, {   6,  47 },
+        {   2,  55 }, {  13,  41 }, {  10,  44 }, {   6,  50 },
+        {   5,  53 }, {  13,  49 }, {   4,  63 }, {   6,  64 },
+        {  -2,  69 }, {  -2,  59 }, {   6,  70 }, {  10,  44 },
+        {   9,  31 }, {  12,  43 }, {   3,  53 }, {  14,  34 },
+        {  10,  38 }, {  -3,  52 }, {  13,  40 }, {  17,  32 },
+        {   7,  44 }, {   7,  38 }, {  13,  50 }, {  10,  57 },
+        {  26,  43 },
+
+        /* 338 - 398 */
+        {  14,  11 }, {  11,  14 }, {   9,  11 }, {  18,  11 },
+        {  21,   9 }, {  23,  -2 }, {  32, -15 }, {  32, -15 },
+        {  34, -21 }, {  39, -23 }, {  42, -33 }, {  41, -31 },
+        {  46, -28 }, {  38, -12 }, {  21,  29 }, {  45, -24 },
+        {  53, -45 }, {  48, -26 }, {  65, -43 }, {  43, -19 },
+        {  39, -10 }, {  30,   9 }, {  18,  26 }, {  20,  27 },
+        {   0,  57 }, { -14,  82 }, {  -5,  75 }, { -19,  97 },
+        { -35, 125 }, {  27,   0 }, {  28,   0 }, {  31,  -4 },
+        {  27,   6 }, {  34,   8 }, {  30,  10 }, {  24,  22 },
+        {  33,  19 }, {  22,  32 }, {  26,  31 }, {  21,  41 },
+        {  26,  44 }, {  23,  47 }, {  16,  65 }, {  14,  71 },
+        {   8,  60 }, {   6,  63 }, {  17,  65 }, {  21,  24 },
+        {  23,  20 }, {  26,  23 }, {  27,  32 }, {  28,  23 },
+        {  28,  24 }, {  23,  40 }, {  24,  32 }, {  28,  29 },
+        {  23,  42 }, {  19,  57 }, {  22,  53 }, {  22,  61 },
+        {  11,  86 },
+
+        /* 399 -> 435 */
+        {  12,  40 }, {  11,  51 }, {  14,  59 },
+        {  -4,  79 }, {  -7,  71 }, {  -5,  69 }, {  -9,  70 },
+        {  -8,  66 }, { -10,  68 }, { -19,  73 }, { -12,  69 },
+        { -16,  70 }, { -15,  67 }, { -20,  62 }, { -19,  70 },
+        { -16,  66 }, { -22,  65 }, { -20,  63 }, {   9,  -2 },
+        {  26,  -9 }, {  33,  -9 }, {  39,  -7 }, {  41,  -2 },
+        {  45,   3 }, {  49,   9 }, {  45,  27 }, {  36,  59 },
+        {  -6,  66 }, {  -7,  35 }, {  -7,  42 }, {  -8,  45 },
+        {  -5,  48 }, { -12,  56 }, {  -6,  60 }, {  -5,  62 },
+        {  -8,  66 }, {  -8,  76 },
+
+        /* 436 -> 459 */
+        {  -5,  85 }, {  -6,  81 }, { -10,  77 }, {  -7,  81 },
+        { -17,  80 }, { -18,  73 }, {  -4,  74 }, { -10,  83 },
+        {  -9,  71 }, {  -9,  67 }, {  -1,  61 }, {  -8,  66 },
+        { -14,  66 }, {   0,  59 }, {   2,  59 }, {  21, -13 },
+        {  33, -14 }, {  39,  -7 }, {  46,  -2 }, {  51,   2 },
+        {  60,   6 }, {  61,  17 }, {  55,  34 }, {  42,  62 },
+
+        /* 460 - 1024 */
+        {  -7,  92 }, {  -5,  89 }, {  -7,  96 }, { -13, 108 },
+        {  -3,  46 }, {  -1,  65 }, {  -1,  57 }, {  -9,  93 },
+        {  -3,  74 }, {  -9,  92 }, {  -8,  87 }, { -23, 126 },
+        {  -7,  92 }, {  -5,  89 }, {  -7,  96 }, { -13, 108 },
+        {  -3,  46 }, {  -1,  65 }, {  -1,  57 }, {  -9,  93 },
+        {  -3,  74 }, {  -9,  92 }, {  -8,  87 }, { -23, 126 },
+        {  -2,  85 }, {  -6,  78 }, {  -1,  75 }, {  -7,  77 },
+        {   2,  54 }, {   5,  50 }, {  -3,  68 }, {   1,  50 },
+        {   6,  42 }, {  -4,  81 }, {   1,  63 }, {  -4,  70 },
+        {   0,  67 }, {   2,  57 }, {  -2,  76 }, {  11,  35 },
+        {   4,  64 }, {   1,  61 }, {  11,  35 }, {  18,  25 },
+        {  12,  24 }, {  13,  29 }, {  13,  36 }, { -10,  93 },
+        {  -7,  73 }, {  -2,  73 }, {  13,  46 }, {   9,  49 },
+        {  -7, 100 }, {   9,  53 }, {   2,  53 }, {   5,  53 },
+        {  -2,  61 }, {   0,  56 }, {   0,  56 }, { -13,  63 },
+        {  -5,  60 }, {  -1,  62 }, {   4,  57 }, {  -6,  69 },
+        {   4,  57 }, {  14,  39 }, {   4,  51 }, {  13,  68 },
+        {  -2,  85 }, {  -6,  78 }, {  -1,  75 }, {  -7,  77 },
+        {   2,  54 }, {   5,  50 }, {  -3,  68 }, {   1,  50 },
+        {   6,  42 }, {  -4,  81 }, {   1,  63 }, {  -4,  70 },
+        {   0,  67 }, {   2,  57 }, {  -2,  76 }, {  11,  35 },
+        {   4,  64 }, {   1,  61 }, {  11,  35 }, {  18,  25 },
+        {  12,  24 }, {  13,  29 }, {  13,  36 }, { -10,  93 },
+        {  -7,  73 }, {  -2,  73 }, {  13,  46 }, {   9,  49 },
+        {  -7, 100 }, {   9,  53 }, {   2,  53 }, {   5,  53 },
+        {  -2,  61 }, {   0,  56 }, {   0,  56 }, { -13,  63 },
+        {  -5,  60 }, {  -1,  62 }, {   4,  57 }, {  -6,  69 },
+        {   4,  57 }, {  14,  39 }, {   4,  51 }, {  13,  68 },
+        {  11,  28 }, {   2,  40 }, {   3,  44 }, {   0,  49 },
+        {   0,  46 }, {   2,  44 }, {   2,  51 }, {   0,  47 },
+        {   4,  39 }, {   2,  62 }, {   6,  46 }, {   0,  54 },
+        {   3,  54 }, {   2,  58 }, {   4,  63 }, {   6,  51 },
+        {   6,  57 }, {   7,  53 }, {   6,  52 }, {   6,  55 },
+        {  11,  45 }, {  14,  36 }, {   8,  53 }, {  -1,  82 },
+        {   7,  55 }, {  -3,  78 }, {  15,  46 }, {  22,  31 },
+        {  -1,  84 }, {  25,   7 }, {  30,  -7 }, {  28,   3 },
+        {  28,   4 }, {  32,   0 }, {  34,  -1 }, {  30,   6 },
+        {  30,   6 }, {  32,   9 }, {  31,  19 }, {  26,  27 },
+        {  26,  30 }, {  37,  20 }, {  28,  34 }, {  17,  70 },
+        {  11,  28 }, {   2,  40 }, {   3,  44 }, {   0,  49 },
+        {   0,  46 }, {   2,  44 }, {   2,  51 }, {   0,  47 },
+        {   4,  39 }, {   2,  62 }, {   6,  46 }, {   0,  54 },
+        {   3,  54 }, {   2,  58 }, {   4,  63 }, {   6,  51 },
+        {   6,  57 }, {   7,  53 }, {   6,  52 }, {   6,  55 },
+        {  11,  45 }, {  14,  36 }, {   8,  53 }, {  -1,  82 },
+        {   7,  55 }, {  -3,  78 }, {  15,  46 }, {  22,  31 },
+        {  -1,  84 }, {  25,   7 }, {  30,  -7 }, {  28,   3 },
+        {  28,   4 }, {  32,   0 }, {  34,  -1 }, {  30,   6 },
+        {  30,   6 }, {  32,   9 }, {  31,  19 }, {  26,  27 },
+        {  26,  30 }, {  37,  20 }, {  28,  34 }, {  17,  70 },
+        {  -4,  79 }, {  -7,  71 }, {  -5,  69 }, {  -9,  70 },
+        {  -8,  66 }, { -10,  68 }, { -19,  73 }, { -12,  69 },
+        { -16,  70 }, { -15,  67 }, { -20,  62 }, { -19,  70 },
+        { -16,  66 }, { -22,  65 }, { -20,  63 }, {  -5,  85 },
+        {  -6,  81 }, { -10,  77 }, {  -7,  81 }, { -17,  80 },
+        { -18,  73 }, {  -4,  74 }, { -10,  83 }, {  -9,  71 },
+        {  -9,  67 }, {  -1,  61 }, {  -8,  66 }, { -14,  66 },
+        {   0,  59 }, {   2,  59 }, {   9,  -2 }, {  26,  -9 },
+        {  33,  -9 }, {  39,  -7 }, {  41,  -2 }, {  45,   3 },
+        {  49,   9 }, {  45,  27 }, {  36,  59 }, {  21, -13 },
+        {  33, -14 }, {  39,  -7 }, {  46,  -2 }, {  51,   2 },
+        {  60,   6 }, {  61,  17 }, {  55,  34 }, {  42,  62 },
+        {  -6,  66 }, {  -7,  35 }, {  -7,  42 }, {  -8,  45 },
+        {  -5,  48 }, { -12,  56 }, {  -6,  60 }, {  -5,  62 },
+        {  -8,  66 }, {  -8,  76 }, {  -4,  79 }, {  -7,  71 },
+        {  -5,  69 }, {  -9,  70 }, {  -8,  66 }, { -10,  68 },
+        { -19,  73 }, { -12,  69 }, { -16,  70 }, { -15,  67 },
+        { -20,  62 }, { -19,  70 }, { -16,  66 }, { -22,  65 },
+        { -20,  63 }, {  -5,  85 }, {  -6,  81 }, { -10,  77 },
+        {  -7,  81 }, { -17,  80 }, { -18,  73 }, {  -4,  74 },
+        { -10,  83 }, {  -9,  71 }, {  -9,  67 }, {  -1,  61 },
+        {  -8,  66 }, { -14,  66 }, {   0,  59 }, {   2,  59 },
+        {   9,  -2 }, {  26,  -9 }, {  33,  -9 }, {  39,  -7 },
+        {  41,  -2 }, {  45,   3 }, {  49,   9 }, {  45,  27 },
+        {  36,  59 }, {  21, -13 }, {  33, -14 }, {  39,  -7 },
+        {  46,  -2 }, {  51,   2 }, {  60,   6 }, {  61,  17 },
+        {  55,  34 }, {  42,  62 }, {  -6,  66 }, {  -7,  35 },
+        {  -7,  42 }, {  -8,  45 }, {  -5,  48 }, { -12,  56 },
+        {  -6,  60 }, {  -5,  62 }, {  -8,  66 }, {  -8,  76 },
+        { -13, 106 }, { -16, 106 }, { -10,  87 }, { -21, 114 },
+        { -18, 110 }, { -14,  98 }, { -22, 110 }, { -21, 106 },
+        { -18, 103 }, { -21, 107 }, { -23, 108 }, { -26, 112 },
+        { -10,  96 }, { -12,  95 }, {  -5,  91 }, {  -9,  93 },
+        { -22,  94 }, {  -5,  86 }, {   9,  67 }, {  -4,  80 },
+        { -10,  85 }, {  -1,  70 }, {   7,  60 }, {   9,  58 },
+        {   5,  61 }, {  12,  50 }, {  15,  50 }, {  18,  49 },
+        {  17,  54 }, {  10,  41 }, {   7,  46 }, {  -1,  51 },
+        {   7,  49 }, {   8,  52 }, {   9,  41 }, {   6,  47 },
+        {   2,  55 }, {  13,  41 }, {  10,  44 }, {   6,  50 },
+        {   5,  53 }, {  13,  49 }, {   4,  63 }, {   6,  64 },
+        { -13, 106 }, { -16, 106 }, { -10,  87 }, { -21, 114 },
+        { -18, 110 }, { -14,  98 }, { -22, 110 }, { -21, 106 },
+        { -18, 103 }, { -21, 107 }, { -23, 108 }, { -26, 112 },
+        { -10,  96 }, { -12,  95 }, {  -5,  91 }, {  -9,  93 },
+        { -22,  94 }, {  -5,  86 }, {   9,  67 }, {  -4,  80 },
+        { -10,  85 }, {  -1,  70 }, {   7,  60 }, {   9,  58 },
+        {   5,  61 }, {  12,  50 }, {  15,  50 }, {  18,  49 },
+        {  17,  54 }, {  10,  41 }, {   7,  46 }, {  -1,  51 },
+        {   7,  49 }, {   8,  52 }, {   9,  41 }, {   6,  47 },
+        {   2,  55 }, {  13,  41 }, {  10,  44 }, {   6,  50 },
+        {   5,  53 }, {  13,  49 }, {   4,  63 }, {   6,  64 },
+        {  14,  11 }, {  11,  14 }, {   9,  11 }, {  18,  11 },
+        {  21,   9 }, {  23,  -2 }, {  32, -15 }, {  32, -15 },
+        {  34, -21 }, {  39, -23 }, {  42, -33 }, {  41, -31 },
+        {  46, -28 }, {  38, -12 }, {  21,  29 }, {  45, -24 },
+        {  53, -45 }, {  48, -26 }, {  65, -43 }, {  43, -19 },
+        {  39, -10 }, {  30,   9 }, {  18,  26 }, {  20,  27 },
+        {   0,  57 }, { -14,  82 }, {  -5,  75 }, { -19,  97 },
+        { -35, 125 }, {  27,   0 }, {  28,   0 }, {  31,  -4 },
+        {  27,   6 }, {  34,   8 }, {  30,  10 }, {  24,  22 },
+        {  33,  19 }, {  22,  32 }, {  26,  31 }, {  21,  41 },
+        {  26,  44 }, {  23,  47 }, {  16,  65 }, {  14,  71 },
+        {  14,  11 }, {  11,  14 }, {   9,  11 }, {  18,  11 },
+        {  21,   9 }, {  23,  -2 }, {  32, -15 }, {  32, -15 },
+        {  34, -21 }, {  39, -23 }, {  42, -33 }, {  41, -31 },
+        {  46, -28 }, {  38, -12 }, {  21,  29 }, {  45, -24 },
+        {  53, -45 }, {  48, -26 }, {  65, -43 }, {  43, -19 },
+        {  39, -10 }, {  30,   9 }, {  18,  26 }, {  20,  27 },
+        {   0,  57 }, { -14,  82 }, {  -5,  75 }, { -19,  97 },
+        { -35, 125 }, {  27,   0 }, {  28,   0 }, {  31,  -4 },
+        {  27,   6 }, {  34,   8 }, {  30,  10 }, {  24,  22 },
+        {  33,  19 }, {  22,  32 }, {  26,  31 }, {  21,  41 },
+        {  26,  44 }, {  23,  47 }, {  16,  65 }, {  14,  71 },
+        {  -6,  76 }, {  -2,  44 }, {   0,  45 }, {   0,  52 },
+        {  -3,  64 }, {  -2,  59 }, {  -4,  70 }, {  -4,  75 },
+        {  -8,  82 }, { -17, 102 }, {  -9,  77 }, {   3,  24 },
+        {   0,  42 }, {   0,  48 }, {   0,  55 }, {  -6,  59 },
+        {  -7,  71 }, { -12,  83 }, { -11,  87 }, { -30, 119 },
+        {   1,  58 }, {  -3,  29 }, {  -1,  36 }, {   1,  38 },
+        {   2,  43 }, {  -6,  55 }, {   0,  58 }, {   0,  64 },
+        {  -3,  74 }, { -10,  90 }, {  -6,  76 }, {  -2,  44 },
+        {   0,  45 }, {   0,  52 }, {  -3,  64 }, {  -2,  59 },
+        {  -4,  70 }, {  -4,  75 }, {  -8,  82 }, { -17, 102 },
+        {  -9,  77 }, {   3,  24 }, {   0,  42 }, {   0,  48 },
+        {   0,  55 }, {  -6,  59 }, {  -7,  71 }, { -12,  83 },
+        { -11,  87 }, { -30, 119 }, {   1,  58 }, {  -3,  29 },
+        {  -1,  36 }, {   1,  38 }, {   2,  43 }, {  -6,  55 },
+        {   0,  58 }, {   0,  64 }, {  -3,  74 }, { -10,  90 },
+        {  -3,  74 }, {  -9,  92 }, {  -8,  87 }, { -23, 126 },
+        {  -3,  74 }, {  -9,  92 }, {  -8,  87 }, { -23, 126 },
+        {  -3,  74 }, {  -9,  92 }, {  -8,  87 }, { -23, 126 }
+    },
+
+    /* i_cabac_init_idc == 1 */
+    {
+        /* 0 - 10 */
+        {  20, -15 }, {   2,  54 }, {   3,  74 }, {  20, -15 },
+        {   2,  54 }, {   3,  74 }, { -28, 127 }, { -23, 104 },
+        {  -6,  53 }, {  -1,  54 }, {   7,  51 },
+
+        /* 11 - 23 */
+        {  22,  25 }, {  34,   0 }, {  16,   0 }, {  -2,   9 },
+        {   4,  41 }, { -29, 118 }, {   2,  65 }, {  -6,  71 },
+        { -13,  79 }, {   5,  52 }, {   9,  50 }, {  -3,  70 },
+        {  10,  54 },
+
+        /* 24 - 39 */
+        {  26,  34 }, {  19,  22 }, {  40,   0 }, {  57,   2 },
+        {  41,  36 }, {  26,  69 }, { -45, 127 }, { -15, 101 },
+        {  -4,  76 }, {  -6,  71 }, { -13,  79 }, {   5,  52 },
+        {   6,  69 }, { -13,  90 }, {   0,  52 }, {   8,  43 },
+
+        /* 40 - 53 */
+        {  -2,  69 },{  -5,  82 },{ -10,  96 },{   2,  59 },
+        {   2,  75 },{  -3,  87 },{  -3,  100 },{   1,  56 },
+        {  -3,  74 },{  -6,  85 },{   0,  59 },{  -3,  81 },
+        {  -7,  86 },{  -5,  95 },
+
+        /* 54 - 59 */
+        {  -1,  66 },{  -1,  77 },{   1,  70 },{  -2,  86 },
+        {  -5,  72 },{   0,  61 },
+
+        /* 60 - 69 */
+        { 0, 41 },   { 0, 63 },   { 0, 63 },     { 0, 63 },
+        { -9, 83 },  { 4, 86 },   { 0, 97 },     { -7, 72 },
+        { 13, 41 },  { 3, 62 },
+
+        /* 70 - 104 */
+        {  13,  15 }, {   7,  51 }, {   2,  80 }, { -39, 127 },
+        { -18,  91 }, { -17,  96 }, { -26,  81 }, { -35,  98 },
+        { -24, 102 }, { -23,  97 }, { -27, 119 }, { -24,  99 },
+        { -21, 110 }, { -18, 102 }, { -36, 127 }, {   0,  80 },
+        {  -5,  89 }, {  -7,  94 }, {  -4,  92 }, {   0,  39 },
+        {   0,  65 }, { -15,  84 }, { -35, 127 }, {  -2,  73 },
+        { -12, 104 }, {  -9,  91 }, { -31, 127 }, {   3,  55 },
+        {   7,  56 }, {   7,  55 }, {   8,  61 }, {  -3,  53 },
+        {   0,  68 }, {  -7,  74 }, {  -9,  88 },
+
+        /* 105 -> 165 */
+        { -13, 103 }, { -13,  91 }, {  -9,  89 }, { -14,  92 },
+        {  -8,  76 }, { -12,  87 }, { -23, 110 }, { -24, 105 },
+        { -10,  78 }, { -20, 112 }, { -17,  99 }, { -78, 127 },
+        { -70, 127 }, { -50, 127 }, { -46, 127 }, {  -4,  66 },
+        {  -5,  78 }, {  -4,  71 }, {  -8,  72 }, {   2,  59 },
+        {  -1,  55 }, {  -7,  70 }, {  -6,  75 }, {  -8,  89 },
+        { -34, 119 }, {  -3,  75 }, {  32,  20 }, {  30,  22 },
+        { -44, 127 }, {   0,  54 }, {  -5,  61 }, {   0,  58 },
+        {  -1,  60 }, {  -3,  61 }, {  -8,  67 }, { -25,  84 },
+        { -14,  74 }, {  -5,  65 }, {   5,  52 }, {   2,  57 },
+        {   0,  61 }, {  -9,  69 }, { -11,  70 }, {  18,  55 },
+        {  -4,  71 }, {   0,  58 }, {   7,  61 }, {   9,  41 },
+        {  18,  25 }, {   9,  32 }, {   5,  43 }, {   9,  47 },
+        {   0,  44 }, {   0,  51 }, {   2,  46 }, {  19,  38 },
+        {  -4,  66 }, {  15,  38 }, {  12,  42 }, {   9,  34 },
+        {   0,  89 },
+
+        /* 166 - 226 */
+        {   4,  45 }, {  10,  28 }, {  10,  31 }, {  33, -11 },
+        {  52, -43 }, {  18,  15 }, {  28,   0 }, {  35, -22 },
+        {  38, -25 }, {  34,   0 }, {  39, -18 }, {  32, -12 },
+        { 102, -94 }, {   0,   0 }, {  56, -15 }, {  33,  -4 },
+        {  29,  10 }, {  37,  -5 }, {  51, -29 }, {  39,  -9 },
+        {  52, -34 }, {  69, -58 }, {  67, -63 }, {  44,  -5 },
+        {  32,   7 }, {  55, -29 }, {  32,   1 }, {   0,   0 },
+        {  27,  36 }, {  33, -25 }, {  34, -30 }, {  36, -28 },
+        {  38, -28 }, {  38, -27 }, {  34, -18 }, {  35, -16 },
+        {  34, -14 }, {  32,  -8 }, {  37,  -6 }, {  35,   0 },
+        {  30,  10 }, {  28,  18 }, {  26,  25 }, {  29,  41 },
+        {   0,  75 }, {   2,  72 }, {   8,  77 }, {  14,  35 },
+        {  18,  31 }, {  17,  35 }, {  21,  30 }, {  17,  45 },
+        {  20,  42 }, {  18,  45 }, {  27,  26 }, {  16,  54 },
+        {   7,  66 }, {  16,  56 }, {  11,  73 }, {  10,  67 },
+        { -10, 116 },
+
+        /* 227 - 275 */
+        { -23, 112 }, { -15,  71 }, {  -7,  61 }, {   0,  53 },
+        {  -5,  66 }, { -11,  77 }, {  -9,  80 }, {  -9,  84 },
+        { -10,  87 }, { -34, 127 }, { -21, 101 }, {  -3,  39 },
+        {  -5,  53 }, {  -7,  61 }, { -11,  75 }, { -15,  77 },
+        { -17,  91 }, { -25, 107 }, { -25, 111 }, { -28, 122 },
+        { -11,  76 }, { -10,  44 }, { -10,  52 }, { -10,  57 },
+        {  -9,  58 }, { -16,  72 }, {  -7,  69 }, {  -4,  69 },
+        {  -5,  74 }, {  -9,  86 }, {   2,  66 }, {  -9,  34 },
+        {   1,  32 }, {  11,  31 }, {   5,  52 }, {  -2,  55 },
+        {  -2,  67 }, {   0,  73 }, {  -8,  89 }, {   3,  52 },
+        {   7,   4 }, {  10,   8 }, {  17,   8 }, {  16,  19 },
+        {   3,  37 }, {  -1,  61 }, {  -5,  73 }, {  -1,  70 },
+        {  -4,  78 },
+
+        /* 276 a bit special (not used, x264_cabac_encode_bypass is used instead) */
+        { 0, 0 },
+
+        /* 277 - 337 */
+        { -21, 126 }, { -23, 124 }, { -20, 110 }, { -26, 126 },
+        { -25, 124 }, { -17, 105 }, { -27, 121 }, { -27, 117 },
+        { -17, 102 }, { -26, 117 }, { -27, 116 }, { -33, 122 },
+        { -10,  95 }, { -14, 100 }, {  -8,  95 }, { -17, 111 },
+        { -28, 114 }, {  -6,  89 }, {  -2,  80 }, {  -4,  82 },
+        {  -9,  85 }, {  -8,  81 }, {  -1,  72 }, {   5,  64 },
+        {   1,  67 }, {   9,  56 }, {   0,  69 }, {   1,  69 },
+        {   7,  69 }, {  -7,  69 }, {  -6,  67 }, { -16,  77 },
+        {  -2,  64 }, {   2,  61 }, {  -6,  67 }, {  -3,  64 },
+        {   2,  57 }, {  -3,  65 }, {  -3,  66 }, {   0,  62 },
+        {   9,  51 }, {  -1,  66 }, {  -2,  71 }, {  -2,  75 },
+        {  -1,  70 }, {  -9,  72 }, {  14,  60 }, {  16,  37 },
+        {   0,  47 }, {  18,  35 }, {  11,  37 }, {  12,  41 },
+        {  10,  41 }, {   2,  48 }, {  12,  41 }, {  13,  41 },
+        {   0,  59 }, {   3,  50 }, {  19,  40 }, {   3,  66 },
+        {  18,  50 },
+
+        /* 338 - 398 */
+        {  19,  -6 }, {  18,  -6 }, {  14,   0 }, {  26, -12 },
+        {  31, -16 }, {  33, -25 }, {  33, -22 }, {  37, -28 },
+        {  39, -30 }, {  42, -30 }, {  47, -42 }, {  45, -36 },
+        {  49, -34 }, {  41, -17 }, {  32,   9 }, {  69, -71 },
+        {  63, -63 }, {  66, -64 }, {  77, -74 }, {  54, -39 },
+        {  52, -35 }, {  41, -10 }, {  36,   0 }, {  40,  -1 },
+        {  30,  14 }, {  28,  26 }, {  23,  37 }, {  12,  55 },
+        {  11,  65 }, {  37, -33 }, {  39, -36 }, {  40, -37 },
+        {  38, -30 }, {  46, -33 }, {  42, -30 }, {  40, -24 },
+        {  49, -29 }, {  38, -12 }, {  40, -10 }, {  38,  -3 },
+        {  46,  -5 }, {  31,  20 }, {  29,  30 }, {  25,  44 },
+        {  12,  48 }, {  11,  49 }, {  26,  45 }, {  22,  22 },
+        {  23,  22 }, {  27,  21 }, {  33,  20 }, {  26,  28 },
+        {  30,  24 }, {  27,  34 }, {  18,  42 }, {  25,  39 },
+        {  18,  50 }, {  12,  70 }, {  21,  54 }, {  14,  71 },
+        {  11,  83 },
+
+        /* 399 -> 435 */
+        {  25,  32 }, {  21,  49 }, {  21,  54 },
+        {  -5,  85 }, {  -6,  81 }, { -10,  77 }, {  -7,  81 },
+        { -17,  80 }, { -18,  73 }, {  -4,  74 }, { -10,  83 },
+        {  -9,  71 }, {  -9,  67 }, {  -1,  61 }, {  -8,  66 },
+        { -14,  66 }, {   0,  59 }, {   2,  59 }, {  17, -10 },
+        {  32, -13 }, {  42,  -9 }, {  49,  -5 }, {  53,   0 },
+        {  64,   3 }, {  68,  10 }, {  66,  27 }, {  47,  57 },
+        {  -5,  71 }, {   0,  24 }, {  -1,  36 }, {  -2,  42 },
+        {  -2,  52 }, {  -9,  57 }, {  -6,  63 }, {  -4,  65 },
+        {  -4,  67 }, {  -7,  82 },
+
+        /* 436 -> 459 */
+        {  -3,  81 }, {  -3,  76 }, {  -7,  72 }, {  -6,  78 },
+        { -12,  72 }, { -14,  68 }, {  -3,  70 }, {  -6,  76 },
+        {  -5,  66 }, {  -5,  62 }, {   0,  57 }, {  -4,  61 },
+        {  -9,  60 }, {   1,  54 }, {   2,  58 }, {  17, -10 },
+        {  32, -13 }, {  42,  -9 }, {  49,  -5 }, {  53,   0 },
+        {  64,   3 }, {  68,  10 }, {  66,  27 }, {  47,  57 },
+
+        /* 460 - 1024 */
+        {   0,  80 }, {  -5,  89 }, {  -7,  94 }, {  -4,  92 },
+        {   0,  39 }, {   0,  65 }, { -15,  84 }, { -35, 127 },
+        {  -2,  73 }, { -12, 104 }, {  -9,  91 }, { -31, 127 },
+        {   0,  80 }, {  -5,  89 }, {  -7,  94 }, {  -4,  92 },
+        {   0,  39 }, {   0,  65 }, { -15,  84 }, { -35, 127 },
+        {  -2,  73 }, { -12, 104 }, {  -9,  91 }, { -31, 127 },
+        { -13, 103 }, { -13,  91 }, {  -9,  89 }, { -14,  92 },
+        {  -8,  76 }, { -12,  87 }, { -23, 110 }, { -24, 105 },
+        { -10,  78 }, { -20, 112 }, { -17,  99 }, { -78, 127 },
+        { -70, 127 }, { -50, 127 }, { -46, 127 }, {  -4,  66 },
+        {  -5,  78 }, {  -4,  71 }, {  -8,  72 }, {   2,  59 },
+        {  -1,  55 }, {  -7,  70 }, {  -6,  75 }, {  -8,  89 },
+        { -34, 119 }, {  -3,  75 }, {  32,  20 }, {  30,  22 },
+        { -44, 127 }, {   0,  54 }, {  -5,  61 }, {   0,  58 },
+        {  -1,  60 }, {  -3,  61 }, {  -8,  67 }, { -25,  84 },
+        { -14,  74 }, {  -5,  65 }, {   5,  52 }, {   2,  57 },
+        {   0,  61 }, {  -9,  69 }, { -11,  70 }, {  18,  55 },
+        { -13, 103 }, { -13,  91 }, {  -9,  89 }, { -14,  92 },
+        {  -8,  76 }, { -12,  87 }, { -23, 110 }, { -24, 105 },
+        { -10,  78 }, { -20, 112 }, { -17,  99 }, { -78, 127 },
+        { -70, 127 }, { -50, 127 }, { -46, 127 }, {  -4,  66 },
+        {  -5,  78 }, {  -4,  71 }, {  -8,  72 }, {   2,  59 },
+        {  -1,  55 }, {  -7,  70 }, {  -6,  75 }, {  -8,  89 },
+        { -34, 119 }, {  -3,  75 }, {  32,  20 }, {  30,  22 },
+        { -44, 127 }, {   0,  54 }, {  -5,  61 }, {   0,  58 },
+        {  -1,  60 }, {  -3,  61 }, {  -8,  67 }, { -25,  84 },
+        { -14,  74 }, {  -5,  65 }, {   5,  52 }, {   2,  57 },
+        {   0,  61 }, {  -9,  69 }, { -11,  70 }, {  18,  55 },
+        {   4,  45 }, {  10,  28 }, {  10,  31 }, {  33, -11 },
+        {  52, -43 }, {  18,  15 }, {  28,   0 }, {  35, -22 },
+        {  38, -25 }, {  34,   0 }, {  39, -18 }, {  32, -12 },
+        { 102, -94 }, {   0,   0 }, {  56, -15 }, {  33,  -4 },
+        {  29,  10 }, {  37,  -5 }, {  51, -29 }, {  39,  -9 },
+        {  52, -34 }, {  69, -58 }, {  67, -63 }, {  44,  -5 },
+        {  32,   7 }, {  55, -29 }, {  32,   1 }, {   0,   0 },
+        {  27,  36 }, {  33, -25 }, {  34, -30 }, {  36, -28 },
+        {  38, -28 }, {  38, -27 }, {  34, -18 }, {  35, -16 },
+        {  34, -14 }, {  32,  -8 }, {  37,  -6 }, {  35,   0 },
+        {  30,  10 }, {  28,  18 }, {  26,  25 }, {  29,  41 },
+        {   4,  45 }, {  10,  28 }, {  10,  31 }, {  33, -11 },
+        {  52, -43 }, {  18,  15 }, {  28,   0 }, {  35, -22 },
+        {  38, -25 }, {  34,   0 }, {  39, -18 }, {  32, -12 },
+        { 102, -94 }, {   0,   0 }, {  56, -15 }, {  33,  -4 },
+        {  29,  10 }, {  37,  -5 }, {  51, -29 }, {  39,  -9 },
+        {  52, -34 }, {  69, -58 }, {  67, -63 }, {  44,  -5 },
+        {  32,   7 }, {  55, -29 }, {  32,   1 }, {   0,   0 },
+        {  27,  36 }, {  33, -25 }, {  34, -30 }, {  36, -28 },
+        {  38, -28 }, {  38, -27 }, {  34, -18 }, {  35, -16 },
+        {  34, -14 }, {  32,  -8 }, {  37,  -6 }, {  35,   0 },
+        {  30,  10 }, {  28,  18 }, {  26,  25 }, {  29,  41 },
+        {  -5,  85 }, {  -6,  81 }, { -10,  77 }, {  -7,  81 },
+        { -17,  80 }, { -18,  73 }, {  -4,  74 }, { -10,  83 },
+        {  -9,  71 }, {  -9,  67 }, {  -1,  61 }, {  -8,  66 },
+        { -14,  66 }, {   0,  59 }, {   2,  59 }, {  -3,  81 },
+        {  -3,  76 }, {  -7,  72 }, {  -6,  78 }, { -12,  72 },
+        { -14,  68 }, {  -3,  70 }, {  -6,  76 }, {  -5,  66 },
+        {  -5,  62 }, {   0,  57 }, {  -4,  61 }, {  -9,  60 },
+        {   1,  54 }, {   2,  58 }, {  17, -10 }, {  32, -13 },
+        {  42,  -9 }, {  49,  -5 }, {  53,   0 }, {  64,   3 },
+        {  68,  10 }, {  66,  27 }, {  47,  57 }, {  17, -10 },
+        {  32, -13 }, {  42,  -9 }, {  49,  -5 }, {  53,   0 },
+        {  64,   3 }, {  68,  10 }, {  66,  27 }, {  47,  57 },
+        {  -5,  71 }, {   0,  24 }, {  -1,  36 }, {  -2,  42 },
+        {  -2,  52 }, {  -9,  57 }, {  -6,  63 }, {  -4,  65 },
+        {  -4,  67 }, {  -7,  82 }, {  -5,  85 }, {  -6,  81 },
+        { -10,  77 }, {  -7,  81 }, { -17,  80 }, { -18,  73 },
+        {  -4,  74 }, { -10,  83 }, {  -9,  71 }, {  -9,  67 },
+        {  -1,  61 }, {  -8,  66 }, { -14,  66 }, {   0,  59 },
+        {   2,  59 }, {  -3,  81 }, {  -3,  76 }, {  -7,  72 },
+        {  -6,  78 }, { -12,  72 }, { -14,  68 }, {  -3,  70 },
+        {  -6,  76 }, {  -5,  66 }, {  -5,  62 }, {   0,  57 },
+        {  -4,  61 }, {  -9,  60 }, {   1,  54 }, {   2,  58 },
+        {  17, -10 }, {  32, -13 }, {  42,  -9 }, {  49,  -5 },
+        {  53,   0 }, {  64,   3 }, {  68,  10 }, {  66,  27 },
+        {  47,  57 }, {  17, -10 }, {  32, -13 }, {  42,  -9 },
+        {  49,  -5 }, {  53,   0 }, {  64,   3 }, {  68,  10 },
+        {  66,  27 }, {  47,  57 }, {  -5,  71 }, {   0,  24 },
+        {  -1,  36 }, {  -2,  42 }, {  -2,  52 }, {  -9,  57 },
+        {  -6,  63 }, {  -4,  65 }, {  -4,  67 }, {  -7,  82 },
+        { -21, 126 }, { -23, 124 }, { -20, 110 }, { -26, 126 },
+        { -25, 124 }, { -17, 105 }, { -27, 121 }, { -27, 117 },
+        { -17, 102 }, { -26, 117 }, { -27, 116 }, { -33, 122 },
+        { -10,  95 }, { -14, 100 }, {  -8,  95 }, { -17, 111 },
+        { -28, 114 }, {  -6,  89 }, {  -2,  80 }, {  -4,  82 },
+        {  -9,  85 }, {  -8,  81 }, {  -1,  72 }, {   5,  64 },
+        {   1,  67 }, {   9,  56 }, {   0,  69 }, {   1,  69 },
+        {   7,  69 }, {  -7,  69 }, {  -6,  67 }, { -16,  77 },
+        {  -2,  64 }, {   2,  61 }, {  -6,  67 }, {  -3,  64 },
+        {   2,  57 }, {  -3,  65 }, {  -3,  66 }, {   0,  62 },
+        {   9,  51 }, {  -1,  66 }, {  -2,  71 }, {  -2,  75 },
+        { -21, 126 }, { -23, 124 }, { -20, 110 }, { -26, 126 },
+        { -25, 124 }, { -17, 105 }, { -27, 121 }, { -27, 117 },
+        { -17, 102 }, { -26, 117 }, { -27, 116 }, { -33, 122 },
+        { -10,  95 }, { -14, 100 }, {  -8,  95 }, { -17, 111 },
+        { -28, 114 }, {  -6,  89 }, {  -2,  80 }, {  -4,  82 },
+        {  -9,  85 }, {  -8,  81 }, {  -1,  72 }, {   5,  64 },
+        {   1,  67 }, {   9,  56 }, {   0,  69 }, {   1,  69 },
+        {   7,  69 }, {  -7,  69 }, {  -6,  67 }, { -16,  77 },
+        {  -2,  64 }, {   2,  61 }, {  -6,  67 }, {  -3,  64 },
+        {   2,  57 }, {  -3,  65 }, {  -3,  66 }, {   0,  62 },
+        {   9,  51 }, {  -1,  66 }, {  -2,  71 }, {  -2,  75 },
+        {  19,  -6 }, {  18,  -6 }, {  14,   0 }, {  26, -12 },
+        {  31, -16 }, {  33, -25 }, {  33, -22 }, {  37, -28 },
+        {  39, -30 }, {  42, -30 }, {  47, -42 }, {  45, -36 },
+        {  49, -34 }, {  41, -17 }, {  32,   9 }, {  69, -71 },
+        {  63, -63 }, {  66, -64 }, {  77, -74 }, {  54, -39 },
+        {  52, -35 }, {  41, -10 }, {  36,   0 }, {  40,  -1 },
+        {  30,  14 }, {  28,  26 }, {  23,  37 }, {  12,  55 },
+        {  11,  65 }, {  37, -33 }, {  39, -36 }, {  40, -37 },
+        {  38, -30 }, {  46, -33 }, {  42, -30 }, {  40, -24 },
+        {  49, -29 }, {  38, -12 }, {  40, -10 }, {  38,  -3 },
+        {  46,  -5 }, {  31,  20 }, {  29,  30 }, {  25,  44 },
+        {  19,  -6 }, {  18,  -6 }, {  14,   0 }, {  26, -12 },
+        {  31, -16 }, {  33, -25 }, {  33, -22 }, {  37, -28 },
+        {  39, -30 }, {  42, -30 }, {  47, -42 }, {  45, -36 },
+        {  49, -34 }, {  41, -17 }, {  32,   9 }, {  69, -71 },
+        {  63, -63 }, {  66, -64 }, {  77, -74 }, {  54, -39 },
+        {  52, -35 }, {  41, -10 }, {  36,   0 }, {  40,  -1 },
+        {  30,  14 }, {  28,  26 }, {  23,  37 }, {  12,  55 },
+        {  11,  65 }, {  37, -33 }, {  39, -36 }, {  40, -37 },
+        {  38, -30 }, {  46, -33 }, {  42, -30 }, {  40, -24 },
+        {  49, -29 }, {  38, -12 }, {  40, -10 }, {  38,  -3 },
+        {  46,  -5 }, {  31,  20 }, {  29,  30 }, {  25,  44 },
+        { -23, 112 }, { -15,  71 }, {  -7,  61 }, {   0,  53 },
+        {  -5,  66 }, { -11,  77 }, {  -9,  80 }, {  -9,  84 },
+        { -10,  87 }, { -34, 127 }, { -21, 101 }, {  -3,  39 },
+        {  -5,  53 }, {  -7,  61 }, { -11,  75 }, { -15,  77 },
+        { -17,  91 }, { -25, 107 }, { -25, 111 }, { -28, 122 },
+        { -11,  76 }, { -10,  44 }, { -10,  52 }, { -10,  57 },
+        {  -9,  58 }, { -16,  72 }, {  -7,  69 }, {  -4,  69 },
+        {  -5,  74 }, {  -9,  86 }, { -23, 112 }, { -15,  71 },
+        {  -7,  61 }, {   0,  53 }, {  -5,  66 }, { -11,  77 },
+        {  -9,  80 }, {  -9,  84 }, { -10,  87 }, { -34, 127 },
+        { -21, 101 }, {  -3,  39 }, {  -5,  53 }, {  -7,  61 },
+        { -11,  75 }, { -15,  77 }, { -17,  91 }, { -25, 107 },
+        { -25, 111 }, { -28, 122 }, { -11,  76 }, { -10,  44 },
+        { -10,  52 }, { -10,  57 }, {  -9,  58 }, { -16,  72 },
+        {  -7,  69 }, {  -4,  69 }, {  -5,  74 }, {  -9,  86 },
+        {  -2,  73 }, { -12, 104 }, {  -9,  91 }, { -31, 127 },
+        {  -2,  73 }, { -12, 104 }, {  -9,  91 }, { -31, 127 },
+        {  -2,  73 }, { -12, 104 }, {  -9,  91 }, { -31, 127 }
+    },
+
+    /* i_cabac_init_idc == 2 */
+    {
+        /* 0 - 10 */
+        {  20, -15 }, {   2,  54 }, {   3,  74 }, {  20, -15 },
+        {   2,  54 }, {   3,  74 }, { -28, 127 }, { -23, 104 },
+        {  -6,  53 }, {  -1,  54 }, {   7,  51 },
+
+        /* 11 - 23 */
+        {  29,  16 }, {  25,   0 }, {  14,   0 }, { -10,  51 },
+        {  -3,  62 }, { -27,  99 }, {  26,  16 }, {  -4,  85 },
+        { -24, 102 }, {   5,  57 }, {   6,  57 }, { -17,  73 },
+        {  14,  57 },
+
+        /* 24 - 39 */
+        {  20,  40 }, {  20,  10 }, {  29,   0 }, {  54,   0 },
+        {  37,  42 }, {  12,  97 }, { -32, 127 }, { -22, 117 },
+        {  -2,  74 }, {  -4,  85 }, { -24, 102 }, {   5,  57 },
+        {  -6,  93 }, { -14,  88 }, {  -6,  44 }, {   4,  55 },
+
+        /* 40 - 53 */
+        { -11,  89 },{ -15,  103 },{ -21,  116 },{  19,  57 },
+        {  20,  58 },{   4,  84 },{   6,  96 },{   1,  63 },
+        {  -5,  85 },{ -13,  106 },{   5,  63 },{   6,  75 },
+        {  -3,  90 },{  -1,  101 },
+
+        /* 54 - 59 */
+        {   3,  55 },{  -4,  79 },{  -2,  75 },{ -12,  97 },
+        {  -7,  50 },{   1,  60 },
+
+        /* 60 - 69 */
+        { 0, 41 },   { 0, 63 },   { 0, 63 },     { 0, 63 },
+        { -9, 83 },  { 4, 86 },   { 0, 97 },     { -7, 72 },
+        { 13, 41 },  { 3, 62 },
+
+        /* 70 - 104 */
+        {   7,  34 }, {  -9,  88 }, { -20, 127 }, { -36, 127 },
+        { -17,  91 }, { -14,  95 }, { -25,  84 }, { -25,  86 },
+        { -12,  89 }, { -17,  91 }, { -31, 127 }, { -14,  76 },
+        { -18, 103 }, { -13,  90 }, { -37, 127 }, {  11,  80 },
+        {   5,  76 }, {   2,  84 }, {   5,  78 }, {  -6,  55 },
+        {   4,  61 }, { -14,  83 }, { -37, 127 }, {  -5,  79 },
+        { -11, 104 }, { -11,  91 }, { -30, 127 }, {   0,  65 },
+        {  -2,  79 }, {   0,  72 }, {  -4,  92 }, {  -6,  56 },
+        {   3,  68 }, {  -8,  71 }, { -13,  98 },
+
+        /* 105 -> 165 */
+        {  -4,  86 }, { -12,  88 }, {  -5,  82 }, {  -3,  72 },
+        {  -4,  67 }, {  -8,  72 }, { -16,  89 }, {  -9,  69 },
+        {  -1,  59 }, {   5,  66 }, {   4,  57 }, {  -4,  71 },
+        {  -2,  71 }, {   2,  58 }, {  -1,  74 }, {  -4,  44 },
+        {  -1,  69 }, {   0,  62 }, {  -7,  51 }, {  -4,  47 },
+        {  -6,  42 }, {  -3,  41 }, {  -6,  53 }, {   8,  76 },
+        {  -9,  78 }, { -11,  83 }, {   9,  52 }, {   0,  67 },
+        {  -5,  90 }, {   1,  67 }, { -15,  72 }, {  -5,  75 },
+        {  -8,  80 }, { -21,  83 }, { -21,  64 }, { -13,  31 },
+        { -25,  64 }, { -29,  94 }, {   9,  75 }, {  17,  63 },
+        {  -8,  74 }, {  -5,  35 }, {  -2,  27 }, {  13,  91 },
+        {   3,  65 }, {  -7,  69 }, {   8,  77 }, { -10,  66 },
+        {   3,  62 }, {  -3,  68 }, { -20,  81 }, {   0,  30 },
+        {   1,   7 }, {  -3,  23 }, { -21,  74 }, {  16,  66 },
+        { -23, 124 }, {  17,  37 }, {  44, -18 }, {  50, -34 },
+        { -22, 127 },
+
+        /* 166 - 226 */
+        {   4,  39 }, {   0,  42 }, {   7,  34 }, {  11,  29 },
+        {   8,  31 }, {   6,  37 }, {   7,  42 }, {   3,  40 },
+        {   8,  33 }, {  13,  43 }, {  13,  36 }, {   4,  47 },
+        {   3,  55 }, {   2,  58 }, {   6,  60 }, {   8,  44 },
+        {  11,  44 }, {  14,  42 }, {   7,  48 }, {   4,  56 },
+        {   4,  52 }, {  13,  37 }, {   9,  49 }, {  19,  58 },
+        {  10,  48 }, {  12,  45 }, {   0,  69 }, {  20,  33 },
+        {   8,  63 }, {  35, -18 }, {  33, -25 }, {  28,  -3 },
+        {  24,  10 }, {  27,   0 }, {  34, -14 }, {  52, -44 },
+        {  39, -24 }, {  19,  17 }, {  31,  25 }, {  36,  29 },
+        {  24,  33 }, {  34,  15 }, {  30,  20 }, {  22,  73 },
+        {  20,  34 }, {  19,  31 }, {  27,  44 }, {  19,  16 },
+        {  15,  36 }, {  15,  36 }, {  21,  28 }, {  25,  21 },
+        {  30,  20 }, {  31,  12 }, {  27,  16 }, {  24,  42 },
+        {   0,  93 }, {  14,  56 }, {  15,  57 }, {  26,  38 },
+        { -24, 127 },
+
+        /* 227 - 275 */
+        { -24, 115 }, { -22,  82 }, {  -9,  62 }, {   0,  53 },
+        {   0,  59 }, { -14,  85 }, { -13,  89 }, { -13,  94 },
+        { -11,  92 }, { -29, 127 }, { -21, 100 }, { -14,  57 },
+        { -12,  67 }, { -11,  71 }, { -10,  77 }, { -21,  85 },
+        { -16,  88 }, { -23, 104 }, { -15,  98 }, { -37, 127 },
+        { -10,  82 }, {  -8,  48 }, {  -8,  61 }, {  -8,  66 },
+        {  -7,  70 }, { -14,  75 }, { -10,  79 }, {  -9,  83 },
+        { -12,  92 }, { -18, 108 }, {  -4,  79 }, { -22,  69 },
+        { -16,  75 }, {  -2,  58 }, {   1,  58 }, { -13,  78 },
+        {  -9,  83 }, {  -4,  81 }, { -13,  99 }, { -13,  81 },
+        {  -6,  38 }, { -13,  62 }, {  -6,  58 }, {  -2,  59 },
+        { -16,  73 }, { -10,  76 }, { -13,  86 }, {  -9,  83 },
+        { -10,  87 },
+
+        /* 276 a bit special (not used, x264_cabac_encode_bypass is used instead) */
+        { 0, 0 },
+
+        /* 277 - 337 */
+        { -22, 127 }, { -25, 127 }, { -25, 120 }, { -27, 127 },
+        { -19, 114 }, { -23, 117 }, { -25, 118 }, { -26, 117 },
+        { -24, 113 }, { -28, 118 }, { -31, 120 }, { -37, 124 },
+        { -10,  94 }, { -15, 102 }, { -10,  99 }, { -13, 106 },
+        { -50, 127 }, {  -5,  92 }, {  17,  57 }, {  -5,  86 },
+        { -13,  94 }, { -12,  91 }, {  -2,  77 }, {   0,  71 },
+        {  -1,  73 }, {   4,  64 }, {  -7,  81 }, {   5,  64 },
+        {  15,  57 }, {   1,  67 }, {   0,  68 }, { -10,  67 },
+        {   1,  68 }, {   0,  77 }, {   2,  64 }, {   0,  68 },
+        {  -5,  78 }, {   7,  55 }, {   5,  59 }, {   2,  65 },
+        {  14,  54 }, {  15,  44 }, {   5,  60 }, {   2,  70 },
+        {  -2,  76 }, { -18,  86 }, {  12,  70 }, {   5,  64 },
+        { -12,  70 }, {  11,  55 }, {   5,  56 }, {   0,  69 },
+        {   2,  65 }, {  -6,  74 }, {   5,  54 }, {   7,  54 },
+        {  -6,  76 }, { -11,  82 }, {  -2,  77 }, {  -2,  77 },
+        {  25,  42 },
+
+        /* 338 - 398 */
+        {  17, -13 }, {  16,  -9 }, {  17, -12 }, {  27, -21 },
+        {  37, -30 }, {  41, -40 }, {  42, -41 }, {  48, -47 },
+        {  39, -32 }, {  46, -40 }, {  52, -51 }, {  46, -41 },
+        {  52, -39 }, {  43, -19 }, {  32,  11 }, {  61, -55 },
+        {  56, -46 }, {  62, -50 }, {  81, -67 }, {  45, -20 },
+        {  35,  -2 }, {  28,  15 }, {  34,   1 }, {  39,   1 },
+        {  30,  17 }, {  20,  38 }, {  18,  45 }, {  15,  54 },
+        {   0,  79 }, {  36, -16 }, {  37, -14 }, {  37, -17 },
+        {  32,   1 }, {  34,  15 }, {  29,  15 }, {  24,  25 },
+        {  34,  22 }, {  31,  16 }, {  35,  18 }, {  31,  28 },
+        {  33,  41 }, {  36,  28 }, {  27,  47 }, {  21,  62 },
+        {  18,  31 }, {  19,  26 }, {  36,  24 }, {  24,  23 },
+        {  27,  16 }, {  24,  30 }, {  31,  29 }, {  22,  41 },
+        {  22,  42 }, {  16,  60 }, {  15,  52 }, {  14,  60 },
+        {   3,  78 }, { -16, 123 }, {  21,  53 }, {  22,  56 },
+        {  25,  61 },
+
+        /* 399 -> 435 */
+        {  21,  33 }, {  19,  50 }, {  17,  61 },
+        {  -3,  78 }, {  -8,  74 }, {  -9,  72 }, { -10,  72 },
+        { -18,  75 }, { -12,  71 }, { -11,  63 }, {  -5,  70 },
+        { -17,  75 }, { -14,  72 }, { -16,  67 }, {  -8,  53 },
+        { -14,  59 }, {  -9,  52 }, { -11,  68 }, {   9,  -2 },
+        {  30, -10 }, {  31,  -4 }, {  33,  -1 }, {  33,   7 },
+        {  31,  12 }, {  37,  23 }, {  31,  38 }, {  20,  64 },
+        {  -9,  71 }, {  -7,  37 }, {  -8,  44 }, { -11,  49 },
+        { -10,  56 }, { -12,  59 }, {  -8,  63 }, {  -9,  67 },
+        {  -6,  68 }, { -10,  79 },
+
+        /* 436 -> 459 */
+        {  -3,  78 }, {  -8,  74 }, {  -9,  72 }, { -10,  72 },
+        { -18,  75 }, { -12,  71 }, { -11,  63 }, {  -5,  70 },
+        { -17,  75 }, { -14,  72 }, { -16,  67 }, {  -8,  53 },
+        { -14,  59 }, {  -9,  52 }, { -11,  68 }, {   9,  -2 },
+        {  30, -10 }, {  31,  -4 }, {  33,  -1 }, {  33,   7 },
+        {  31,  12 }, {  37,  23 }, {  31,  38 }, {  20,  64 },
+
+        /* 460 - 1024 */
+        {  11,  80 }, {   5,  76 }, {   2,  84 }, {   5,  78 },
+        {  -6,  55 }, {   4,  61 }, { -14,  83 }, { -37, 127 },
+        {  -5,  79 }, { -11, 104 }, { -11,  91 }, { -30, 127 },
+        {  11,  80 }, {   5,  76 }, {   2,  84 }, {   5,  78 },
+        {  -6,  55 }, {   4,  61 }, { -14,  83 }, { -37, 127 },
+        {  -5,  79 }, { -11, 104 }, { -11,  91 }, { -30, 127 },
+        {  -4,  86 }, { -12,  88 }, {  -5,  82 }, {  -3,  72 },
+        {  -4,  67 }, {  -8,  72 }, { -16,  89 }, {  -9,  69 },
+        {  -1,  59 }, {   5,  66 }, {   4,  57 }, {  -4,  71 },
+        {  -2,  71 }, {   2,  58 }, {  -1,  74 }, {  -4,  44 },
+        {  -1,  69 }, {   0,  62 }, {  -7,  51 }, {  -4,  47 },
+        {  -6,  42 }, {  -3,  41 }, {  -6,  53 }, {   8,  76 },
+        {  -9,  78 }, { -11,  83 }, {   9,  52 }, {   0,  67 },
+        {  -5,  90 }, {   1,  67 }, { -15,  72 }, {  -5,  75 },
+        {  -8,  80 }, { -21,  83 }, { -21,  64 }, { -13,  31 },
+        { -25,  64 }, { -29,  94 }, {   9,  75 }, {  17,  63 },
+        {  -8,  74 }, {  -5,  35 }, {  -2,  27 }, {  13,  91 },
+        {  -4,  86 }, { -12,  88 }, {  -5,  82 }, {  -3,  72 },
+        {  -4,  67 }, {  -8,  72 }, { -16,  89 }, {  -9,  69 },
+        {  -1,  59 }, {   5,  66 }, {   4,  57 }, {  -4,  71 },
+        {  -2,  71 }, {   2,  58 }, {  -1,  74 }, {  -4,  44 },
+        {  -1,  69 }, {   0,  62 }, {  -7,  51 }, {  -4,  47 },
+        {  -6,  42 }, {  -3,  41 }, {  -6,  53 }, {   8,  76 },
+        {  -9,  78 }, { -11,  83 }, {   9,  52 }, {   0,  67 },
+        {  -5,  90 }, {   1,  67 }, { -15,  72 }, {  -5,  75 },
+        {  -8,  80 }, { -21,  83 }, { -21,  64 }, { -13,  31 },
+        { -25,  64 }, { -29,  94 }, {   9,  75 }, {  17,  63 },
+        {  -8,  74 }, {  -5,  35 }, {  -2,  27 }, {  13,  91 },
+        {   4,  39 }, {   0,  42 }, {   7,  34 }, {  11,  29 },
+        {   8,  31 }, {   6,  37 }, {   7,  42 }, {   3,  40 },
+        {   8,  33 }, {  13,  43 }, {  13,  36 }, {   4,  47 },
+        {   3,  55 }, {   2,  58 }, {   6,  60 }, {   8,  44 },
+        {  11,  44 }, {  14,  42 }, {   7,  48 }, {   4,  56 },
+        {   4,  52 }, {  13,  37 }, {   9,  49 }, {  19,  58 },
+        {  10,  48 }, {  12,  45 }, {   0,  69 }, {  20,  33 },
+        {   8,  63 }, {  35, -18 }, {  33, -25 }, {  28,  -3 },
+        {  24,  10 }, {  27,   0 }, {  34, -14 }, {  52, -44 },
+        {  39, -24 }, {  19,  17 }, {  31,  25 }, {  36,  29 },
+        {  24,  33 }, {  34,  15 }, {  30,  20 }, {  22,  73 },
+        {   4,  39 }, {   0,  42 }, {   7,  34 }, {  11,  29 },
+        {   8,  31 }, {   6,  37 }, {   7,  42 }, {   3,  40 },
+        {   8,  33 }, {  13,  43 }, {  13,  36 }, {   4,  47 },
+        {   3,  55 }, {   2,  58 }, {   6,  60 }, {   8,  44 },
+        {  11,  44 }, {  14,  42 }, {   7,  48 }, {   4,  56 },
+        {   4,  52 }, {  13,  37 }, {   9,  49 }, {  19,  58 },
+        {  10,  48 }, {  12,  45 }, {   0,  69 }, {  20,  33 },
+        {   8,  63 }, {  35, -18 }, {  33, -25 }, {  28,  -3 },
+        {  24,  10 }, {  27,   0 }, {  34, -14 }, {  52, -44 },
+        {  39, -24 }, {  19,  17 }, {  31,  25 }, {  36,  29 },
+        {  24,  33 }, {  34,  15 }, {  30,  20 }, {  22,  73 },
+        {  -3,  78 }, {  -8,  74 }, {  -9,  72 }, { -10,  72 },
+        { -18,  75 }, { -12,  71 }, { -11,  63 }, {  -5,  70 },
+        { -17,  75 }, { -14,  72 }, { -16,  67 }, {  -8,  53 },
+        { -14,  59 }, {  -9,  52 }, { -11,  68 }, {  -3,  78 },
+        {  -8,  74 }, {  -9,  72 }, { -10,  72 }, { -18,  75 },
+        { -12,  71 }, { -11,  63 }, {  -5,  70 }, { -17,  75 },
+        { -14,  72 }, { -16,  67 }, {  -8,  53 }, { -14,  59 },
+        {  -9,  52 }, { -11,  68 }, {   9,  -2 }, {  30, -10 },
+        {  31,  -4 }, {  33,  -1 }, {  33,   7 }, {  31,  12 },
+        {  37,  23 }, {  31,  38 }, {  20,  64 }, {   9,  -2 },
+        {  30, -10 }, {  31,  -4 }, {  33,  -1 }, {  33,   7 },
+        {  31,  12 }, {  37,  23 }, {  31,  38 }, {  20,  64 },
+        {  -9,  71 }, {  -7,  37 }, {  -8,  44 }, { -11,  49 },
+        { -10,  56 }, { -12,  59 }, {  -8,  63 }, {  -9,  67 },
+        {  -6,  68 }, { -10,  79 }, {  -3,  78 }, {  -8,  74 },
+        {  -9,  72 }, { -10,  72 }, { -18,  75 }, { -12,  71 },
+        { -11,  63 }, {  -5,  70 }, { -17,  75 }, { -14,  72 },
+        { -16,  67 }, {  -8,  53 }, { -14,  59 }, {  -9,  52 },
+        { -11,  68 }, {  -3,  78 }, {  -8,  74 }, {  -9,  72 },
+        { -10,  72 }, { -18,  75 }, { -12,  71 }, { -11,  63 },
+        {  -5,  70 }, { -17,  75 }, { -14,  72 }, { -16,  67 },
+        {  -8,  53 }, { -14,  59 }, {  -9,  52 }, { -11,  68 },
+        {   9,  -2 }, {  30, -10 }, {  31,  -4 }, {  33,  -1 },
+        {  33,   7 }, {  31,  12 }, {  37,  23 }, {  31,  38 },
+        {  20,  64 }, {   9,  -2 }, {  30, -10 }, {  31,  -4 },
+        {  33,  -1 }, {  33,   7 }, {  31,  12 }, {  37,  23 },
+        {  31,  38 }, {  20,  64 }, {  -9,  71 }, {  -7,  37 },
+        {  -8,  44 }, { -11,  49 }, { -10,  56 }, { -12,  59 },
+        {  -8,  63 }, {  -9,  67 }, {  -6,  68 }, { -10,  79 },
+        { -22, 127 }, { -25, 127 }, { -25, 120 }, { -27, 127 },
+        { -19, 114 }, { -23, 117 }, { -25, 118 }, { -26, 117 },
+        { -24, 113 }, { -28, 118 }, { -31, 120 }, { -37, 124 },
+        { -10,  94 }, { -15, 102 }, { -10,  99 }, { -13, 106 },
+        { -50, 127 }, {  -5,  92 }, {  17,  57 }, {  -5,  86 },
+        { -13,  94 }, { -12,  91 }, {  -2,  77 }, {   0,  71 },
+        {  -1,  73 }, {   4,  64 }, {  -7,  81 }, {   5,  64 },
+        {  15,  57 }, {   1,  67 }, {   0,  68 }, { -10,  67 },
+        {   1,  68 }, {   0,  77 }, {   2,  64 }, {   0,  68 },
+        {  -5,  78 }, {   7,  55 }, {   5,  59 }, {   2,  65 },
+        {  14,  54 }, {  15,  44 }, {   5,  60 }, {   2,  70 },
+        { -22, 127 }, { -25, 127 }, { -25, 120 }, { -27, 127 },
+        { -19, 114 }, { -23, 117 }, { -25, 118 }, { -26, 117 },
+        { -24, 113 }, { -28, 118 }, { -31, 120 }, { -37, 124 },
+        { -10,  94 }, { -15, 102 }, { -10,  99 }, { -13, 106 },
+        { -50, 127 }, {  -5,  92 }, {  17,  57 }, {  -5,  86 },
+        { -13,  94 }, { -12,  91 }, {  -2,  77 }, {   0,  71 },
+        {  -1,  73 }, {   4,  64 }, {  -7,  81 }, {   5,  64 },
+        {  15,  57 }, {   1,  67 }, {   0,  68 }, { -10,  67 },
+        {   1,  68 }, {   0,  77 }, {   2,  64 }, {   0,  68 },
+        {  -5,  78 }, {   7,  55 }, {   5,  59 }, {   2,  65 },
+        {  14,  54 }, {  15,  44 }, {   5,  60 }, {   2,  70 },
+        {  17, -13 }, {  16,  -9 }, {  17, -12 }, {  27, -21 },
+        {  37, -30 }, {  41, -40 }, {  42, -41 }, {  48, -47 },
+        {  39, -32 }, {  46, -40 }, {  52, -51 }, {  46, -41 },
+        {  52, -39 }, {  43, -19 }, {  32,  11 }, {  61, -55 },
+        {  56, -46 }, {  62, -50 }, {  81, -67 }, {  45, -20 },
+        {  35,  -2 }, {  28,  15 }, {  34,   1 }, {  39,   1 },
+        {  30,  17 }, {  20,  38 }, {  18,  45 }, {  15,  54 },
+        {   0,  79 }, {  36, -16 }, {  37, -14 }, {  37, -17 },
+        {  32,   1 }, {  34,  15 }, {  29,  15 }, {  24,  25 },
+        {  34,  22 }, {  31,  16 }, {  35,  18 }, {  31,  28 },
+        {  33,  41 }, {  36,  28 }, {  27,  47 }, {  21,  62 },
+        {  17, -13 }, {  16,  -9 }, {  17, -12 }, {  27, -21 },
+        {  37, -30 }, {  41, -40 }, {  42, -41 }, {  48, -47 },
+        {  39, -32 }, {  46, -40 }, {  52, -51 }, {  46, -41 },
+        {  52, -39 }, {  43, -19 }, {  32,  11 }, {  61, -55 },
+        {  56, -46 }, {  62, -50 }, {  81, -67 }, {  45, -20 },
+        {  35,  -2 }, {  28,  15 }, {  34,   1 }, {  39,   1 },
+        {  30,  17 }, {  20,  38 }, {  18,  45 }, {  15,  54 },
+        {   0,  79 }, {  36, -16 }, {  37, -14 }, {  37, -17 },
+        {  32,   1 }, {  34,  15 }, {  29,  15 }, {  24,  25 },
+        {  34,  22 }, {  31,  16 }, {  35,  18 }, {  31,  28 },
+        {  33,  41 }, {  36,  28 }, {  27,  47 }, {  21,  62 },
+        { -24, 115 }, { -22,  82 }, {  -9,  62 }, {   0,  53 },
+        {   0,  59 }, { -14,  85 }, { -13,  89 }, { -13,  94 },
+        { -11,  92 }, { -29, 127 }, { -21, 100 }, { -14,  57 },
+        { -12,  67 }, { -11,  71 }, { -10,  77 }, { -21,  85 },
+        { -16,  88 }, { -23, 104 }, { -15,  98 }, { -37, 127 },
+        { -10,  82 }, {  -8,  48 }, {  -8,  61 }, {  -8,  66 },
+        {  -7,  70 }, { -14,  75 }, { -10,  79 }, {  -9,  83 },
+        { -12,  92 }, { -18, 108 }, { -24, 115 }, { -22,  82 },
+        {  -9,  62 }, {   0,  53 }, {   0,  59 }, { -14,  85 },
+        { -13,  89 }, { -13,  94 }, { -11,  92 }, { -29, 127 },
+        { -21, 100 }, { -14,  57 }, { -12,  67 }, { -11,  71 },
+        { -10,  77 }, { -21,  85 }, { -16,  88 }, { -23, 104 },
+        { -15,  98 }, { -37, 127 }, { -10,  82 }, {  -8,  48 },
+        {  -8,  61 }, {  -8,  66 }, {  -7,  70 }, { -14,  75 },
+        { -10,  79 }, {  -9,  83 }, { -12,  92 }, { -18, 108 },
+        {  -5,  79 }, { -11, 104 }, { -11,  91 }, { -30, 127 },
+        {  -5,  79 }, { -11, 104 }, { -11,  91 }, { -30, 127 },
+        {  -5,  79 }, { -11, 104 }, { -11,  91 }, { -30, 127 }
+    }
+};
+
+const uint8_t x264_cabac_range_lps[64][4] =
+{
+    {  2,   2,   2,   2}, {  6,   7,   8,   9}, {  6,   7,   9,  10}, {  6,   8,   9,  11},
+    {  7,   8,  10,  11}, {  7,   9,  10,  12}, {  7,   9,  11,  12}, {  8,   9,  11,  13},
+    {  8,  10,  12,  14}, {  9,  11,  12,  14}, {  9,  11,  13,  15}, { 10,  12,  14,  16},
+    { 10,  12,  15,  17}, { 11,  13,  15,  18}, { 11,  14,  16,  19}, { 12,  14,  17,  20},
+    { 12,  15,  18,  21}, { 13,  16,  19,  22}, { 14,  17,  20,  23}, { 14,  18,  21,  24},
+    { 15,  19,  22,  25}, { 16,  20,  23,  27}, { 17,  21,  25,  28}, { 18,  22,  26,  30},
+    { 19,  23,  27,  31}, { 20,  24,  29,  33}, { 21,  26,  30,  35}, { 22,  27,  32,  37},
+    { 23,  28,  33,  39}, { 24,  30,  35,  41}, { 26,  31,  37,  43}, { 27,  33,  39,  45},
+    { 29,  35,  41,  48}, { 30,  37,  43,  50}, { 32,  39,  46,  53}, { 33,  41,  48,  56},
+    { 35,  43,  51,  59}, { 37,  45,  54,  62}, { 39,  48,  56,  65}, { 41,  50,  59,  69},
+    { 43,  53,  63,  72}, { 46,  56,  66,  76}, { 48,  59,  69,  80}, { 51,  62,  73,  85},
+    { 53,  65,  77,  89}, { 56,  69,  81,  94}, { 59,  72,  86,  99}, { 62,  76,  90, 104},
+    { 66,  80,  95, 110}, { 69,  85, 100, 116}, { 73,  89, 105, 122}, { 77,  94, 111, 128},
+    { 81,  99, 117, 135}, { 85, 104, 123, 142}, { 90, 110, 130, 150}, { 95, 116, 137, 158},
+    {100, 122, 144, 166}, {105, 128, 152, 175}, {111, 135, 160, 185}, {116, 142, 169, 195},
+    {123, 150, 178, 205}, {128, 158, 187, 216}, {128, 167, 197, 227}, {128, 176, 208, 240}
+};
+
+const uint8_t x264_cabac_transition[128][2] =
+{
+    {  0,   0}, {  1,   1}, {  2,  50}, { 51,   3}, {  2,  50}, { 51,   3}, {  4,  52}, { 53,   5},
+    {  6,  52}, { 53,   7}, {  8,  52}, { 53,   9}, { 10,  54}, { 55,  11}, { 12,  54}, { 55,  13},
+    { 14,  54}, { 55,  15}, { 16,  56}, { 57,  17}, { 18,  56}, { 57,  19}, { 20,  56}, { 57,  21},
+    { 22,  58}, { 59,  23}, { 24,  58}, { 59,  25}, { 26,  60}, { 61,  27}, { 28,  60}, { 61,  29},
+    { 30,  60}, { 61,  31}, { 32,  62}, { 63,  33}, { 34,  62}, { 63,  35}, { 36,  64}, { 65,  37},
+    { 38,  66}, { 67,  39}, { 40,  66}, { 67,  41}, { 42,  66}, { 67,  43}, { 44,  68}, { 69,  45},
+    { 46,  68}, { 69,  47}, { 48,  70}, { 71,  49}, { 50,  72}, { 73,  51}, { 52,  72}, { 73,  53},
+    { 54,  74}, { 75,  55}, { 56,  74}, { 75,  57}, { 58,  76}, { 77,  59}, { 60,  78}, { 79,  61},
+    { 62,  78}, { 79,  63}, { 64,  80}, { 81,  65}, { 66,  82}, { 83,  67}, { 68,  82}, { 83,  69},
+    { 70,  84}, { 85,  71}, { 72,  84}, { 85,  73}, { 74,  88}, { 89,  75}, { 76,  88}, { 89,  77},
+    { 78,  90}, { 91,  79}, { 80,  90}, { 91,  81}, { 82,  94}, { 95,  83}, { 84,  94}, { 95,  85},
+    { 86,  96}, { 97,  87}, { 88,  96}, { 97,  89}, { 90, 100}, {101,  91}, { 92, 100}, {101,  93},
+    { 94, 102}, {103,  95}, { 96, 104}, {105,  97}, { 98, 104}, {105,  99}, {100, 108}, {109, 101},
+    {102, 108}, {109, 103}, {104, 110}, {111, 105}, {106, 112}, {113, 107}, {108, 114}, {115, 109},
+    {110, 116}, {117, 111}, {112, 118}, {119, 113}, {114, 118}, {119, 115}, {116, 122}, {123, 117},
+    {118, 122}, {123, 119}, {120, 124}, {125, 121}, {122, 126}, {127, 123}, {124, 127}, {126, 125}
+};
+
+const uint8_t x264_cabac_renorm_shift[64] =
+{
+    6,5,4,4,3,3,3,3,2,2,2,2,2,2,2,2,
+    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+};
+
+/* -ln2(probability) */
+const uint16_t x264_cabac_entropy[128] =
+{
+    FIX8(0.0273), FIX8(5.7370), FIX8(0.0288), FIX8(5.6618),
+    FIX8(0.0303), FIX8(5.5866), FIX8(0.0320), FIX8(5.5114),
+    FIX8(0.0337), FIX8(5.4362), FIX8(0.0355), FIX8(5.3610),
+    FIX8(0.0375), FIX8(5.2859), FIX8(0.0395), FIX8(5.2106),
+    FIX8(0.0416), FIX8(5.1354), FIX8(0.0439), FIX8(5.0602),
+    FIX8(0.0463), FIX8(4.9851), FIX8(0.0488), FIX8(4.9099),
+    FIX8(0.0515), FIX8(4.8347), FIX8(0.0543), FIX8(4.7595),
+    FIX8(0.0572), FIX8(4.6843), FIX8(0.0604), FIX8(4.6091),
+    FIX8(0.0637), FIX8(4.5339), FIX8(0.0671), FIX8(4.4588),
+    FIX8(0.0708), FIX8(4.3836), FIX8(0.0747), FIX8(4.3083),
+    FIX8(0.0788), FIX8(4.2332), FIX8(0.0832), FIX8(4.1580),
+    FIX8(0.0878), FIX8(4.0828), FIX8(0.0926), FIX8(4.0076),
+    FIX8(0.0977), FIX8(3.9324), FIX8(0.1032), FIX8(3.8572),
+    FIX8(0.1089), FIX8(3.7820), FIX8(0.1149), FIX8(3.7068),
+    FIX8(0.1214), FIX8(3.6316), FIX8(0.1282), FIX8(3.5565),
+    FIX8(0.1353), FIX8(3.4813), FIX8(0.1429), FIX8(3.4061),
+    FIX8(0.1510), FIX8(3.3309), FIX8(0.1596), FIX8(3.2557),
+    FIX8(0.1686), FIX8(3.1805), FIX8(0.1782), FIX8(3.1053),
+    FIX8(0.1884), FIX8(3.0301), FIX8(0.1992), FIX8(2.9549),
+    FIX8(0.2107), FIX8(2.8797), FIX8(0.2229), FIX8(2.8046),
+    FIX8(0.2358), FIX8(2.7294), FIX8(0.2496), FIX8(2.6542),
+    FIX8(0.2642), FIX8(2.5790), FIX8(0.2798), FIX8(2.5038),
+    FIX8(0.2964), FIX8(2.4286), FIX8(0.3142), FIX8(2.3534),
+    FIX8(0.3331), FIX8(2.2782), FIX8(0.3532), FIX8(2.2030),
+    FIX8(0.3748), FIX8(2.1278), FIX8(0.3979), FIX8(2.0527),
+    FIX8(0.4226), FIX8(1.9775), FIX8(0.4491), FIX8(1.9023),
+    FIX8(0.4776), FIX8(1.8271), FIX8(0.5082), FIX8(1.7519),
+    FIX8(0.5412), FIX8(1.6767), FIX8(0.5768), FIX8(1.6015),
+    FIX8(0.6152), FIX8(1.5263), FIX8(0.6568), FIX8(1.4511),
+    FIX8(0.7020), FIX8(1.3759), FIX8(0.7513), FIX8(1.3008),
+    FIX8(0.8050), FIX8(1.2256), FIX8(0.8638), FIX8(1.1504),
+    FIX8(0.9285), FIX8(1.0752), FIX8(1.0000), FIX8(1.0000)
+};
+
+/*****************************************************************************
+ * RDO
+ *****************************************************************************/
+
+/* Padded to [64] for easier addressing */
+const uint8_t x264_significant_coeff_flag_offset_8x8[2][64] =
+{{
+    0, 1, 2, 3, 4, 5, 5, 4, 4, 3, 3, 4, 4, 4, 5, 5,
+    4, 4, 4, 4, 3, 3, 6, 7, 7, 7, 8, 9,10, 9, 8, 7,
+    7, 6,11,12,13,11, 6, 7, 8, 9,14,10, 9, 8, 6,11,
+   12,13,11, 6, 9,14,10, 9,11,12,13,11,14,10,12
+},{
+    0, 1, 1, 2, 2, 3, 3, 4, 5, 6, 7, 7, 7, 8, 4, 5,
+    6, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,11,12,11,
+    9, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,13,13, 9,
+    9,10,10, 8,13,13, 9, 9,10,10,14,14,14,14,14
+}};
+const uint8_t x264_last_coeff_flag_offset_8x8[63] =
+{
+    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+    3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
+    5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8
+};
+const uint8_t x264_coeff_flag_offset_chroma_422_dc[7] = { 0, 0, 1, 1, 2, 2, 2 }; /* MIN( i/2, 2 ) */
+const uint16_t x264_significant_coeff_flag_offset[2][16] =
+{
+    { 105+0, 105+15, 105+29, 105+44, 105+47, 402, 484+0, 484+15, 484+29, 660, 528+0, 528+15, 528+29, 718, 0, 0 },
+    { 277+0, 277+15, 277+29, 277+44, 277+47, 436, 776+0, 776+15, 776+29, 675, 820+0, 820+15, 820+29, 733, 0, 0 }
+};
+const uint16_t x264_last_coeff_flag_offset[2][16] =
+{
+    { 166+0, 166+15, 166+29, 166+44, 166+47, 417, 572+0, 572+15, 572+29, 690, 616+0, 616+15, 616+29, 748, 0, 0 },
+    { 338+0, 338+15, 338+29, 338+44, 338+47, 451, 864+0, 864+15, 864+29, 699, 908+0, 908+15, 908+29, 757, 0, 0 }
+};
+const uint16_t x264_coeff_abs_level_m1_offset[16] =
+{
+    227+0, 227+10, 227+20, 227+30, 227+39, 426, 952+0, 952+10, 952+20, 708, 982+0, 982+10, 982+20, 766
+};
+const uint8_t x264_count_cat_m1[14] = {15, 14, 15, 3, 14, 63, 15, 14, 15, 63, 15, 14, 15, 63};
+
+/*****************************************************************************
+ * VLC
+ *****************************************************************************/
+
+/* [nC] */
+const vlc_t x264_coeff0_token[6] =
+{
+    { 0x1, 1 }, /* str=1 */
+    { 0x3, 2 }, /* str=11 */
+    { 0xf, 4 }, /* str=1111 */
+    { 0x3, 6 }, /* str=000011 */
+    { 0x1, 2 }, /* str=01 */
+    { 0x1, 1 }, /* str=1 */
+};
+
+/* [nC][i_total_coeff-1][i_trailing] */
+const vlc_t x264_coeff_token[6][16][4] =
+{
+    { /* table 0 */
+        { /* i_total 1 */
+            { 0x5, 6 }, /* str=000101 */
+            { 0x1, 2 }, /* str=01 */
+        },
+        { /* i_total 2 */
+            { 0x7, 8 }, /* str=00000111 */
+            { 0x4, 6 }, /* str=000100 */
+            { 0x1, 3 }, /* str=001 */
+        },
+        { /* i_total 3 */
+            { 0x7, 9 }, /* str=000000111 */
+            { 0x6, 8 }, /* str=00000110 */
+            { 0x5, 7 }, /* str=0000101 */
+            { 0x3, 5 }, /* str=00011 */
+        },
+        { /* i_total 4 */
+            { 0x7, 10 }, /* str=0000000111 */
+            { 0x6, 9 },  /* str=000000110 */
+            { 0x5, 8 },  /* str=00000101 */
+            { 0x3, 6 },  /* str=000011 */
+        },
+        { /* i_total 5 */
+            { 0x7, 11 }, /* str=00000000111 */
+            { 0x6, 10 }, /* str=0000000110 */
+            { 0x5, 9 },  /* str=000000101 */
+            { 0x4, 7 },  /* str=0000100 */
+        },
+        { /* i_total 6 */
+            { 0xf, 13 }, /* str=0000000001111 */
+            { 0x6, 11 }, /* str=00000000110 */
+            { 0x5, 10 }, /* str=0000000101 */
+            { 0x4, 8 },  /* str=00000100 */
+        },
+        { /* i_total 7 */
+            { 0xb, 13 }, /* str=0000000001011 */
+            { 0xe, 13 }, /* str=0000000001110 */
+            { 0x5, 11 }, /* str=00000000101 */
+            { 0x4, 9 },  /* str=000000100 */
+        },
+        { /* i_total 8 */
+            { 0x8, 13 }, /* str=0000000001000 */
+            { 0xa, 13 }, /* str=0000000001010 */
+            { 0xd, 13 }, /* str=0000000001101 */
+            { 0x4, 10 }, /* str=0000000100 */
+        },
+        { /* i_total 9 */
+            { 0xf, 14 }, /* str=00000000001111 */
+            { 0xe, 14 }, /* str=00000000001110 */
+            { 0x9, 13 }, /* str=0000000001001 */
+            { 0x4, 11 }, /* str=00000000100 */
+        },
+        { /* i_total 10 */
+            { 0xb, 14 }, /* str=00000000001011 */
+            { 0xa, 14 }, /* str=00000000001010 */
+            { 0xd, 14 }, /* str=00000000001101 */
+            { 0xc, 13 }, /* str=0000000001100 */
+        },
+        { /* i_total 14 */
+            { 0xf, 15 }, /* str=000000000001111 */
+            { 0xe, 15 }, /* str=000000000001110 */
+            { 0x9, 14 }, /* str=00000000001001 */
+            { 0xc, 14 }, /* str=00000000001100 */
+        },
+        { /* i_total 12 */
+            { 0xb, 15 }, /* str=000000000001011 */
+            { 0xa, 15 }, /* str=000000000001010 */
+            { 0xd, 15 }, /* str=000000000001101 */
+            { 0x8, 14 }, /* str=00000000001000 */
+        },
+        { /* i_total 13 */
+            { 0xf, 16 }, /* str=0000000000001111 */
+            { 0x1, 15 }, /* str=000000000000001 */
+            { 0x9, 15 }, /* str=000000000001001 */
+            { 0xc, 15 }, /* str=000000000001100 */
+        },
+        { /* i_total 14 */
+            { 0xb, 16 }, /* str=0000000000001011 */
+            { 0xe, 16 }, /* str=0000000000001110 */
+            { 0xd, 16 }, /* str=0000000000001101 */
+            { 0x8, 15 }, /* str=000000000001000 */
+        },
+        { /* i_total 15 */
+            { 0x7, 16 }, /* str=0000000000000111 */
+            { 0xa, 16 }, /* str=0000000000001010 */
+            { 0x9, 16 }, /* str=0000000000001001 */
+            { 0xc, 16 }, /* str=0000000000001100 */
+        },
+        { /* i_total 16 */
+            { 0x4, 16 }, /* str=0000000000000100 */
+            { 0x6, 16 }, /* str=0000000000000110 */
+            { 0x5, 16 }, /* str=0000000000000101 */
+            { 0x8, 16 }, /* str=0000000000001000 */
+        },
+    },
+    { /* table 1 */
+        { /* i_total 1 */
+            { 0xb, 6 }, /* str=001011 */
+            { 0x2, 2 }, /* str=10 */
+        },
+        { /* i_total 2 */
+            { 0x7, 6 }, /* str=000111 */
+            { 0x7, 5 }, /* str=00111 */
+            { 0x3, 3 }, /* str=011 */
+        },
+        { /* i_total 3 */
+            { 0x7, 7 }, /* str=0000111 */
+            { 0xa, 6 }, /* str=001010 */
+            { 0x9, 6 }, /* str=001001 */
+            { 0x5, 4 }, /* str=0101 */
+        },
+        { /* i_total 4 */
+            { 0x7, 8 }, /* str=00000111 */
+            { 0x6, 6 }, /* str=000110 */
+            { 0x5, 6 }, /* str=000101 */
+            { 0x4, 4 }, /* str=0100 */
+        },
+        { /* i_total 5 */
+            { 0x4, 8 }, /* str=00000100 */
+            { 0x6, 7 }, /* str=0000110 */
+            { 0x5, 7 }, /* str=0000101 */
+            { 0x6, 5 }, /* str=00110 */
+        },
+        { /* i_total 6 */
+            { 0x7, 9 }, /* str=000000111 */
+            { 0x6, 8 }, /* str=00000110 */
+            { 0x5, 8 }, /* str=00000101 */
+            { 0x8, 6 }, /* str=001000 */
+        },
+        { /* i_total 7 */
+            { 0xf, 11 }, /* str=00000001111 */
+            { 0x6, 9 },  /* str=000000110 */
+            { 0x5, 9 },  /* str=000000101 */
+            { 0x4, 6 },  /* str=000100 */
+        },
+        { /* i_total 8 */
+            { 0xb, 11 }, /* str=00000001011 */
+            { 0xe, 11 }, /* str=00000001110 */
+            { 0xd, 11 }, /* str=00000001101 */
+            { 0x4, 7 },  /* str=0000100 */
+        },
+        { /* i_total 9 */
+            { 0xf, 12 }, /* str=000000001111 */
+            { 0xa, 11 }, /* str=00000001010 */
+            { 0x9, 11 }, /* str=00000001001 */
+            { 0x4, 9 },  /* str=000000100 */
+        },
+        { /* i_total 10 */
+            { 0xb, 12 }, /* str=000000001011 */
+            { 0xe, 12 }, /* str=000000001110 */
+            { 0xd, 12 }, /* str=000000001101 */
+            { 0xc, 11 }, /* str=00000001100 */
+        },
+        { /* i_total 11 */
+            { 0x8, 12 }, /* str=000000001000 */
+            { 0xa, 12 }, /* str=000000001010 */
+            { 0x9, 12 }, /* str=000000001001 */
+            { 0x8, 11 }, /* str=00000001000 */
+        },
+        { /* i_total 12 */
+            { 0xf, 13 }, /* str=0000000001111 */
+            { 0xe, 13 }, /* str=0000000001110 */
+            { 0xd, 13 }, /* str=0000000001101 */
+            { 0xc, 12 }, /* str=000000001100 */
+        },
+        { /* i_total 13 */
+            { 0xb, 13 }, /* str=0000000001011 */
+            { 0xa, 13 }, /* str=0000000001010 */
+            { 0x9, 13 }, /* str=0000000001001 */
+            { 0xc, 13 }, /* str=0000000001100 */
+        },
+        { /* i_total 14 */
+            { 0x7, 13 }, /* str=0000000000111 */
+            { 0xb, 14 }, /* str=00000000001011 */
+            { 0x6, 13 }, /* str=0000000000110 */
+            { 0x8, 13 }, /* str=0000000001000 */
+        },
+        { /* i_total 15 */
+            { 0x9, 14 }, /* str=00000000001001 */
+            { 0x8, 14 }, /* str=00000000001000 */
+            { 0xa, 14 }, /* str=00000000001010 */
+            { 0x1, 13 }, /* str=0000000000001 */
+        },
+        { /* i_total 16 */
+            { 0x7, 14 }, /* str=00000000000111 */
+            { 0x6, 14 }, /* str=00000000000110 */
+            { 0x5, 14 }, /* str=00000000000101 */
+            { 0x4, 14 }, /* str=00000000000100 */
+        },
+    },
+    { /* table 2 */
+        { /* i_total 1 */
+            { 0xf, 6 }, /* str=001111 */
+            { 0xe, 4 }, /* str=1110 */
+        },
+        { /* i_total 2 */
+            { 0xb, 6 }, /* str=001011 */
+            { 0xf, 5 }, /* str=01111 */
+            { 0xd, 4 }, /* str=1101 */
+        },
+        { /* i_total 3 */
+            { 0x8, 6 }, /* str=001000 */
+            { 0xc, 5 }, /* str=01100 */
+            { 0xe, 5 }, /* str=01110 */
+            { 0xc, 4 }, /* str=1100 */
+        },
+        { /* i_total 4 */
+            { 0xf, 7 }, /* str=0001111 */
+            { 0xa, 5 }, /* str=01010 */
+            { 0xb, 5 }, /* str=01011 */
+            { 0xb, 4 }, /* str=1011 */
+        },
+        { /* i_total 5 */
+            { 0xb, 7 }, /* str=0001011 */
+            { 0x8, 5 }, /* str=01000 */
+            { 0x9, 5 }, /* str=01001 */
+            { 0xa, 4 }, /* str=1010 */
+        },
+        { /* i_total 6 */
+            { 0x9, 7 }, /* str=0001001 */
+            { 0xe, 6 }, /* str=001110 */
+            { 0xd, 6 }, /* str=001101 */
+            { 0x9, 4 }, /* str=1001 */
+        },
+        { /* i_total 7 */
+            { 0x8, 7 }, /* str=0001000 */
+            { 0xa, 6 }, /* str=001010 */
+            { 0x9, 6 }, /* str=001001 */
+            { 0x8, 4 }, /* str=1000 */
+        },
+        { /* i_total 8 */
+            { 0xf, 8 }, /* str=00001111 */
+            { 0xe, 7 }, /* str=0001110 */
+            { 0xd, 7 }, /* str=0001101 */
+            { 0xd, 5 }, /* str=01101 */
+        },
+        { /* i_total 9 */
+            { 0xb, 8 }, /* str=00001011 */
+            { 0xe, 8 }, /* str=00001110 */
+            { 0xa, 7 }, /* str=0001010 */
+            { 0xc, 6 }, /* str=001100 */
+        },
+        { /* i_total 10 */
+            { 0xf, 9 }, /* str=000001111 */
+            { 0xa, 8 }, /* str=00001010 */
+            { 0xd, 8 }, /* str=00001101 */
+            { 0xc, 7 }, /* str=0001100 */
+        },
+        { /* i_total 11 */
+            { 0xb, 9 }, /* str=000001011 */
+            { 0xe, 9 }, /* str=000001110 */
+            { 0x9, 8 }, /* str=00001001 */
+            { 0xc, 8 }, /* str=00001100 */
+        },
+        { /* i_total 12 */
+            { 0x8, 9 }, /* str=000001000 */
+            { 0xa, 9 }, /* str=000001010 */
+            { 0xd, 9 }, /* str=000001101 */
+            { 0x8, 8 }, /* str=00001000 */
+        },
+        { /* i_total 13 */
+            { 0xd, 10 }, /* str=0000001101 */
+            { 0x7, 9 },  /* str=000000111 */
+            { 0x9, 9 },  /* str=000001001 */
+            { 0xc, 9 },  /* str=000001100 */
+        },
+        { /* i_total 14 */
+            { 0x9, 10 }, /* str=0000001001 */
+            { 0xc, 10 }, /* str=0000001100 */
+            { 0xb, 10 }, /* str=0000001011 */
+            { 0xa, 10 }, /* str=0000001010 */
+        },
+        { /* i_total 15 */
+            { 0x5, 10 }, /* str=0000000101 */
+            { 0x8, 10 }, /* str=0000001000 */
+            { 0x7, 10 }, /* str=0000000111 */
+            { 0x6, 10 }, /* str=0000000110 */
+        },
+        { /* i_total 16 */
+            { 0x1, 10 }, /* str=0000000001 */
+            { 0x4, 10 }, /* str=0000000100 */
+            { 0x3, 10 }, /* str=0000000011 */
+            { 0x2, 10 }, /* str=0000000010 */
+        },
+    },
+    { /* table 3 */
+        { /* i_total 1 */
+            { 0x0, 6 }, /* str=000000 */
+            { 0x1, 6 }, /* str=000001 */
+        },
+        { /* i_total 2 */
+            { 0x4, 6 }, /* str=000100 */
+            { 0x5, 6 }, /* str=000101 */
+            { 0x6, 6 }, /* str=000110 */
+        },
+        { /* i_total 3 */
+            { 0x8, 6 }, /* str=001000 */
+            { 0x9, 6 }, /* str=001001 */
+            { 0xa, 6 }, /* str=001010 */
+            { 0xb, 6 }, /* str=001011 */
+        },
+        { /* i_total 4 */
+            { 0xc, 6 }, /* str=001100 */
+            { 0xd, 6 }, /* str=001101 */
+            { 0xe, 6 }, /* str=001110 */
+            { 0xf, 6 }, /* str=001111 */
+        },
+        { /* i_total 5 */
+            { 0x10, 6 }, /* str=010000 */
+            { 0x11, 6 }, /* str=010001 */
+            { 0x12, 6 }, /* str=010010 */
+            { 0x13, 6 }, /* str=010011 */
+        },
+        { /* i_total 6 */
+            { 0x14, 6 }, /* str=010100 */
+            { 0x15, 6 }, /* str=010101 */
+            { 0x16, 6 }, /* str=010110 */
+            { 0x17, 6 }, /* str=010111 */
+        },
+        { /* i_total 7 */
+            { 0x18, 6 }, /* str=011000 */
+            { 0x19, 6 }, /* str=011001 */
+            { 0x1a, 6 }, /* str=011010 */
+            { 0x1b, 6 }, /* str=011011 */
+        },
+        { /* i_total 8 */
+            { 0x1c, 6 }, /* str=011100 */
+            { 0x1d, 6 }, /* str=011101 */
+            { 0x1e, 6 }, /* str=011110 */
+            { 0x1f, 6 }, /* str=011111 */
+        },
+        { /* i_total 9 */
+            { 0x20, 6 }, /* str=100000 */
+            { 0x21, 6 }, /* str=100001 */
+            { 0x22, 6 }, /* str=100010 */
+            { 0x23, 6 }, /* str=100011 */
+        },
+        { /* i_total 10 */
+            { 0x24, 6 }, /* str=100100 */
+            { 0x25, 6 }, /* str=100101 */
+            { 0x26, 6 }, /* str=100110 */
+            { 0x27, 6 }, /* str=100111 */
+        },
+        { /* i_total 11 */
+            { 0x28, 6 }, /* str=101000 */
+            { 0x29, 6 }, /* str=101001 */
+            { 0x2a, 6 }, /* str=101010 */
+            { 0x2b, 6 }, /* str=101011 */
+        },
+        { /* i_total 12 */
+            { 0x2c, 6 }, /* str=101100 */
+            { 0x2d, 6 }, /* str=101101 */
+            { 0x2e, 6 }, /* str=101110 */
+            { 0x2f, 6 }, /* str=101111 */
+        },
+        { /* i_total 13 */
+            { 0x30, 6 }, /* str=110000 */
+            { 0x31, 6 }, /* str=110001 */
+            { 0x32, 6 }, /* str=110010 */
+            { 0x33, 6 }, /* str=110011 */
+        },
+        { /* i_total 14 */
+            { 0x34, 6 }, /* str=110100 */
+            { 0x35, 6 }, /* str=110101 */
+            { 0x36, 6 }, /* str=110110 */
+            { 0x37, 6 }, /* str=110111 */
+        },
+        { /* i_total 15 */
+            { 0x38, 6 }, /* str=111000 */
+            { 0x39, 6 }, /* str=111001 */
+            { 0x3a, 6 }, /* str=111010 */
+            { 0x3b, 6 }, /* str=111011 */
+        },
+        { /* i_total 16 */
+            { 0x3c, 6 }, /* str=111100 */
+            { 0x3d, 6 }, /* str=111101 */
+            { 0x3e, 6 }, /* str=111110 */
+            { 0x3f, 6 }, /* str=111111 */
+        },
+    },
+    { /* table 4 */
+        { /* i_total 1 */
+            { 0x7, 6 }, /* str=000111 */
+            { 0x1, 1 }, /* str=1 */
+        },
+        { /* i_total 2 */
+            { 0x4, 6 }, /* str=000100 */
+            { 0x6, 6 }, /* str=000110 */
+            { 0x1, 3 }, /* str=001 */
+        },
+        { /* i_total 3 */
+            { 0x3, 6 }, /* str=000011 */
+            { 0x3, 7 }, /* str=0000011 */
+            { 0x2, 7 }, /* str=0000010 */
+            { 0x5, 6 }, /* str=000101 */
+        },
+        { /* i_total 4 */
+            { 0x2, 6 }, /* str=000010 */
+            { 0x3, 8 }, /* str=00000011 */
+            { 0x2, 8 }, /* str=00000010 */
+            { 0x0, 7 }, /* str=0000000 */
+        },
+    },
+    { /* table 5 */
+        { /* i_total 1 */
+            { 0xf, 7 }, /* str=0001111 */
+            { 0x1, 2 }, /* str=01 */
+        },
+        { /* i_total 2 */
+            { 0xe, 7 }, /* str=0001110 */
+            { 0xd, 7 }, /* str=0001101 */
+            { 0x1, 3 }, /* str=001 */
+        },
+        { /* i_total 3 */
+            { 0x7, 9 }, /* str=000000111 */
+            { 0xc, 7 }, /* str=0001100 */
+            { 0xb, 7 }, /* str=0001011 */
+            { 0x1, 5 }, /* str=00001 */
+        },
+        { /* i_total 4 */
+            { 0x6, 9 }, /* str=000000110 */
+            { 0x5, 9 }, /* str=000000101 */
+            { 0xa, 7 }, /* str=0001010 */
+            { 0x1, 6 }, /* str=000001 */
+        },
+        { /* i_total 5 */
+            { 0x7, 10 }, /* str=0000000111 */
+            { 0x6, 10 }, /* str=0000000110 */
+            { 0x4, 9 },  /* str=000000100 */
+            { 0x9, 7 },  /* str=0001001 */
+        },
+        { /* i_total 6 */
+            { 0x7, 11 }, /* str=00000000111 */
+            { 0x6, 11 }, /* str=00000000110 */
+            { 0x5, 10 }, /* str=0000000101 */
+            { 0x8, 7 },  /* str=0001000 */
+        },
+        { /* i_total 7 */
+            { 0x7, 12 }, /* str=000000000111 */
+            { 0x6, 12 }, /* str=000000000110 */
+            { 0x5, 11 }, /* str=00000000101 */
+            { 0x4, 10 }, /* str=0000000100 */
+        },
+        { /* i_total 8 */
+            { 0x7, 13 }, /* str=0000000000111 */
+            { 0x5, 12 }, /* str=000000000101 */
+            { 0x4, 12 }, /* str=000000000100 */
+            { 0x4, 11 }, /* str=00000000100 */
+        },
+    },
+};
+
+/* [i_total_coeff-1][i_total_zeros] */
+const vlc_t x264_total_zeros[15][16] =
+{
+    { /* i_total 1 */
+        { 0x1, 1 }, /* str=1 */
+        { 0x3, 3 }, /* str=011 */
+        { 0x2, 3 }, /* str=010 */
+        { 0x3, 4 }, /* str=0011 */
+        { 0x2, 4 }, /* str=0010 */
+        { 0x3, 5 }, /* str=00011 */
+        { 0x2, 5 }, /* str=00010 */
+        { 0x3, 6 }, /* str=000011 */
+        { 0x2, 6 }, /* str=000010 */
+        { 0x3, 7 }, /* str=0000011 */
+        { 0x2, 7 }, /* str=0000010 */
+        { 0x3, 8 }, /* str=00000011 */
+        { 0x2, 8 }, /* str=00000010 */
+        { 0x3, 9 }, /* str=000000011 */
+        { 0x2, 9 }, /* str=000000010 */
+        { 0x1, 9 }, /* str=000000001 */
+    },
+    { /* i_total 2 */
+        { 0x7, 3 }, /* str=111 */
+        { 0x6, 3 }, /* str=110 */
+        { 0x5, 3 }, /* str=101 */
+        { 0x4, 3 }, /* str=100 */
+        { 0x3, 3 }, /* str=011 */
+        { 0x5, 4 }, /* str=0101 */
+        { 0x4, 4 }, /* str=0100 */
+        { 0x3, 4 }, /* str=0011 */
+        { 0x2, 4 }, /* str=0010 */
+        { 0x3, 5 }, /* str=00011 */
+        { 0x2, 5 }, /* str=00010 */
+        { 0x3, 6 }, /* str=000011 */
+        { 0x2, 6 }, /* str=000010 */
+        { 0x1, 6 }, /* str=000001 */
+        { 0x0, 6 }, /* str=000000 */
+    },
+    { /* i_total 3 */
+        { 0x5, 4 }, /* str=0101 */
+        { 0x7, 3 }, /* str=111 */
+        { 0x6, 3 }, /* str=110 */
+        { 0x5, 3 }, /* str=101 */
+        { 0x4, 4 }, /* str=0100 */
+        { 0x3, 4 }, /* str=0011 */
+        { 0x4, 3 }, /* str=100 */
+        { 0x3, 3 }, /* str=011 */
+        { 0x2, 4 }, /* str=0010 */
+        { 0x3, 5 }, /* str=00011 */
+        { 0x2, 5 }, /* str=00010 */
+        { 0x1, 6 }, /* str=000001 */
+        { 0x1, 5 }, /* str=00001 */
+        { 0x0, 6 }, /* str=000000 */
+    },
+    { /* i_total 4 */
+        { 0x3, 5 }, /* str=00011 */
+        { 0x7, 3 }, /* str=111 */
+        { 0x5, 4 }, /* str=0101 */
+        { 0x4, 4 }, /* str=0100 */
+        { 0x6, 3 }, /* str=110 */
+        { 0x5, 3 }, /* str=101 */
+        { 0x4, 3 }, /* str=100 */
+        { 0x3, 4 }, /* str=0011 */
+        { 0x3, 3 }, /* str=011 */
+        { 0x2, 4 }, /* str=0010 */
+        { 0x2, 5 }, /* str=00010 */
+        { 0x1, 5 }, /* str=00001 */
+        { 0x0, 5 }, /* str=00000 */
+    },
+    { /* i_total 5 */
+        { 0x5, 4 }, /* str=0101 */
+        { 0x4, 4 }, /* str=0100 */
+        { 0x3, 4 }, /* str=0011 */
+        { 0x7, 3 }, /* str=111 */
+        { 0x6, 3 }, /* str=110 */
+        { 0x5, 3 }, /* str=101 */
+        { 0x4, 3 }, /* str=100 */
+        { 0x3, 3 }, /* str=011 */
+        { 0x2, 4 }, /* str=0010 */
+        { 0x1, 5 }, /* str=00001 */
+        { 0x1, 4 }, /* str=0001 */
+        { 0x0, 5 }, /* str=00000 */
+    },
+    { /* i_total 6 */
+        { 0x1, 6 }, /* str=000001 */
+        { 0x1, 5 }, /* str=00001 */
+        { 0x7, 3 }, /* str=111 */
+        { 0x6, 3 }, /* str=110 */
+        { 0x5, 3 }, /* str=101 */
+        { 0x4, 3 }, /* str=100 */
+        { 0x3, 3 }, /* str=011 */
+        { 0x2, 3 }, /* str=010 */
+        { 0x1, 4 }, /* str=0001 */
+        { 0x1, 3 }, /* str=001 */
+        { 0x0, 6 }, /* str=000000 */
+    },
+    { /* i_total 7 */
+        { 0x1, 6 }, /* str=000001 */
+        { 0x1, 5 }, /* str=00001 */
+        { 0x5, 3 }, /* str=101 */
+        { 0x4, 3 }, /* str=100 */
+        { 0x3, 3 }, /* str=011 */
+        { 0x3, 2 }, /* str=11 */
+        { 0x2, 3 }, /* str=010 */
+        { 0x1, 4 }, /* str=0001 */
+        { 0x1, 3 }, /* str=001 */
+        { 0x0, 6 }, /* str=000000 */
+    },
+    { /* i_total 8 */
+        { 0x1, 6 }, /* str=000001 */
+        { 0x1, 4 }, /* str=0001 */
+        { 0x1, 5 }, /* str=00001 */
+        { 0x3, 3 }, /* str=011 */
+        { 0x3, 2 }, /* str=11 */
+        { 0x2, 2 }, /* str=10 */
+        { 0x2, 3 }, /* str=010 */
+        { 0x1, 3 }, /* str=001 */
+        { 0x0, 6 }, /* str=000000 */
+    },
+    { /* i_total 9 */
+        { 0x1, 6 }, /* str=000001 */
+        { 0x0, 6 }, /* str=000000 */
+        { 0x1, 4 }, /* str=0001 */
+        { 0x3, 2 }, /* str=11 */
+        { 0x2, 2 }, /* str=10 */
+        { 0x1, 3 }, /* str=001 */
+        { 0x1, 2 }, /* str=01 */
+        { 0x1, 5 }, /* str=00001 */
+    },
+    { /* i_total 10 */
+        { 0x1, 5 }, /* str=00001 */
+        { 0x0, 5 }, /* str=00000 */
+        { 0x1, 3 }, /* str=001 */
+        { 0x3, 2 }, /* str=11 */
+        { 0x2, 2 }, /* str=10 */
+        { 0x1, 2 }, /* str=01 */
+        { 0x1, 4 }, /* str=0001 */
+    },
+    { /* i_total 11 */
+        { 0x0, 4 }, /* str=0000 */
+        { 0x1, 4 }, /* str=0001 */
+        { 0x1, 3 }, /* str=001 */
+        { 0x2, 3 }, /* str=010 */
+        { 0x1, 1 }, /* str=1 */
+        { 0x3, 3 }, /* str=011 */
+    },
+    { /* i_total 12 */
+        { 0x0, 4 }, /* str=0000 */
+        { 0x1, 4 }, /* str=0001 */
+        { 0x1, 2 }, /* str=01 */
+        { 0x1, 1 }, /* str=1 */
+        { 0x1, 3 }, /* str=001 */
+    },
+    { /* i_total 13 */
+        { 0x0, 3 }, /* str=000 */
+        { 0x1, 3 }, /* str=001 */
+        { 0x1, 1 }, /* str=1 */
+        { 0x1, 2 }, /* str=01 */
+    },
+    { /* i_total 14 */
+        { 0x0, 2 }, /* str=00 */
+        { 0x1, 2 }, /* str=01 */
+        { 0x1, 1 }, /* str=1 */
+    },
+    { /* i_total 15 */
+        { 0x0, 1 }, /* str=0 */
+        { 0x1, 1 }, /* str=1 */
+    },
+};
+
+/* [i_total_coeff-1][i_total_zeros] */
+const vlc_t x264_total_zeros_2x2_dc[3][4] =
+{
+    { /* i_total 1 */
+        { 0x1, 1 }, /* str=1 */
+        { 0x1, 2 }, /* str=01 */
+        { 0x1, 3 }, /* str=001 */
+        { 0x0, 3 }  /* str=000 */
+    },
+    { /* i_total 2 */
+        { 0x1, 1 }, /* str=1 */
+        { 0x1, 2 }, /* str=01 */
+        { 0x0, 2 }, /* str=00 */
+    },
+    { /* i_total 3 */
+        { 0x1, 1 }, /* str=1 */
+        { 0x0, 1 }, /* str=0 */
+    },
+};
+
+/* [i_total_coeff-1][i_total_zeros] */
+const vlc_t x264_total_zeros_2x4_dc[7][8] =
+{
+    { /* i_total 1 */
+        { 0x1, 1 }, /* str=1 */
+        { 0x2, 3 }, /* str=010 */
+        { 0x3, 3 }, /* str=011 */
+        { 0x2, 4 }, /* str=0010 */
+        { 0x3, 4 }, /* str=0011 */
+        { 0x1, 4 }, /* str=0001 */
+        { 0x1, 5 }, /* str=00001 */
+        { 0x0, 5 }, /* str=00000 */
+    },
+    { /* i_total 2 */
+        { 0x0, 3 }, /* str=000 */
+        { 0x1, 2 }, /* str=01 */
+        { 0x1, 3 }, /* str=001 */
+        { 0x4, 3 }, /* str=100 */
+        { 0x5, 3 }, /* str=101 */
+        { 0x6, 3 }, /* str=110 */
+        { 0x7, 3 }, /* str=111 */
+    },
+    { /* i_total 3 */
+        { 0x0, 3 }, /* str=000 */
+        { 0x1, 3 }, /* str=001 */
+        { 0x1, 2 }, /* str=01 */
+        { 0x2, 2 }, /* str=10 */
+        { 0x6, 3 }, /* str=110 */
+        { 0x7, 3 }, /* str=111 */
+    },
+    { /* i_total 4 */
+        { 0x6, 3 }, /* str=110 */
+        { 0x0, 2 }, /* str=00 */
+        { 0x1, 2 }, /* str=01 */
+        { 0x2, 2 }, /* str=10 */
+        { 0x7, 3 }, /* str=111 */
+    },
+    { /* i_total 5 */
+        { 0x0, 2 }, /* str=00 */
+        { 0x1, 2 }, /* str=01 */
+        { 0x2, 2 }, /* str=10 */
+        { 0x3, 2 }, /* str=11 */
+    },
+    { /* i_total 6 */
+        { 0x0, 2 }, /* str=00 */
+        { 0x1, 2 }, /* str=01 */
+        { 0x1, 1 }, /* str=1 */
+    },
+    { /* i_total 7 */
+        { 0x0, 1 }, /* str=0 */
+        { 0x1, 1 }, /* str=1 */
+    }
+};
+
+/* [MIN( i_zero_left-1, 6 )][run_before] */
+const vlc_t x264_run_before_init[7][16] =
+{
+    { /* i_zero_left 1 */
+        { 0x1, 1 }, /* str=1 */
+        { 0x0, 1 }, /* str=0 */
+    },
+    { /* i_zero_left 2 */
+        { 0x1, 1 }, /* str=1 */
+        { 0x1, 2 }, /* str=01 */
+        { 0x0, 2 }, /* str=00 */
+    },
+    { /* i_zero_left 3 */
+        { 0x3, 2 }, /* str=11 */
+        { 0x2, 2 }, /* str=10 */
+        { 0x1, 2 }, /* str=01 */
+        { 0x0, 2 }, /* str=00 */
+    },
+    { /* i_zero_left 4 */
+        { 0x3, 2 }, /* str=11 */
+        { 0x2, 2 }, /* str=10 */
+        { 0x1, 2 }, /* str=01 */
+        { 0x1, 3 }, /* str=001 */
+        { 0x0, 3 }, /* str=000 */
+    },
+    { /* i_zero_left 5 */
+        { 0x3, 2 }, /* str=11 */
+        { 0x2, 2 }, /* str=10 */
+        { 0x3, 3 }, /* str=011 */
+        { 0x2, 3 }, /* str=010 */
+        { 0x1, 3 }, /* str=001 */
+        { 0x0, 3 }, /* str=000 */
+    },
+    { /* i_zero_left 6 */
+        { 0x3, 2 }, /* str=11 */
+        { 0x0, 3 }, /* str=000 */
+        { 0x1, 3 }, /* str=001 */
+        { 0x3, 3 }, /* str=011 */
+        { 0x2, 3 }, /* str=010 */
+        { 0x5, 3 }, /* str=101 */
+        { 0x4, 3 }, /* str=100 */
+    },
+    { /* i_zero_left >6 */
+        { 0x7, 3 }, /* str=111 */
+        { 0x6, 3 }, /* str=110 */
+        { 0x5, 3 }, /* str=101 */
+        { 0x4, 3 }, /* str=100 */
+        { 0x3, 3 }, /* str=011 */
+        { 0x2, 3 }, /* str=010 */
+        { 0x1, 3 }, /* str=001 */
+        { 0x1, 4 }, /* str=0001 */
+        { 0x1, 5 }, /* str=00001 */
+        { 0x1, 6 }, /* str=000001 */
+        { 0x1, 7 }, /* str=0000001 */
+        { 0x1, 8 }, /* str=00000001 */
+        { 0x1, 9 }, /* str=000000001 */
+        { 0x1, 10 }, /* str=0000000001 */
+        { 0x1, 11 }, /* str=00000000001 */
+    },
+};
diff --git a/common/tables.h b/common/tables.h
new file mode 100644 (file)
index 0000000..6ca74ea
--- /dev/null
@@ -0,0 +1,97 @@
+/*****************************************************************************
+ * tables.h: const tables
+ *****************************************************************************
+ * Copyright (C) 2003-2017 x264 project
+ *
+ * Authors: Laurent Aimar <fenrir@via.ecp.fr>
+ *          Loren Merritt <lorenm@u.washington.edu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@x264.com.
+ *****************************************************************************/
+
+#ifndef X264_TABLES_H
+#define X264_TABLES_H
+
+typedef struct
+{
+    uint8_t i_bits;
+    uint8_t i_size;
+} vlc_t;
+
+extern const x264_level_t x264_levels[];
+
+extern const uint8_t x264_exp2_lut[64];
+extern const float   x264_log2_lut[128];
+extern const float   x264_log2_lz_lut[32];
+
+#define QP_MAX_MAX (51+6*2+18)
+extern const uint16_t x264_lambda_tab[QP_MAX_MAX+1];
+extern const int      x264_lambda2_tab[QP_MAX_MAX+1];
+extern const int      x264_trellis_lambda2_tab[2][QP_MAX_MAX+1];
+#define MAX_CHROMA_LAMBDA_OFFSET 36
+extern const uint16_t x264_chroma_lambda2_offset_tab[MAX_CHROMA_LAMBDA_OFFSET+1];
+
+extern const uint8_t x264_hpel_ref0[16];
+extern const uint8_t x264_hpel_ref1[16];
+
+extern const uint8_t x264_cqm_jvt4i[16];
+extern const uint8_t x264_cqm_jvt4p[16];
+extern const uint8_t x264_cqm_jvt8i[64];
+extern const uint8_t x264_cqm_jvt8p[64];
+extern const uint8_t x264_cqm_flat16[64];
+extern const uint8_t * const x264_cqm_jvt[8];
+extern const uint8_t x264_cqm_avci50_4ic[16];
+extern const uint8_t x264_cqm_avci50_p_8iy[64];
+extern const uint8_t x264_cqm_avci50_1080i_8iy[64];
+extern const uint8_t x264_cqm_avci100_720p_4ic[16];
+extern const uint8_t x264_cqm_avci100_720p_8iy[64];
+extern const uint8_t x264_cqm_avci100_1080_4ic[16];
+extern const uint8_t x264_cqm_avci100_1080i_8iy[64];
+extern const uint8_t x264_cqm_avci100_1080p_8iy[64];
+
+extern const uint8_t x264_decimate_table4[16];
+extern const uint8_t x264_decimate_table8[64];
+
+extern const uint32_t x264_dct4_weight_tab[16];
+extern const uint32_t x264_dct8_weight_tab[64];
+extern const uint32_t x264_dct4_weight2_tab[16];
+extern const uint32_t x264_dct8_weight2_tab[64];
+
+extern const int8_t   x264_cabac_context_init_I[1024][2];
+extern const int8_t   x264_cabac_context_init_PB[3][1024][2];
+extern const uint8_t  x264_cabac_range_lps[64][4];
+extern const uint8_t  x264_cabac_transition[128][2];
+extern const uint8_t  x264_cabac_renorm_shift[64];
+extern const uint16_t x264_cabac_entropy[128];
+
+extern const uint8_t  x264_significant_coeff_flag_offset_8x8[2][64];
+extern const uint8_t  x264_last_coeff_flag_offset_8x8[63];
+extern const uint8_t  x264_coeff_flag_offset_chroma_422_dc[7];
+extern const uint16_t x264_significant_coeff_flag_offset[2][16];
+extern const uint16_t x264_last_coeff_flag_offset[2][16];
+extern const uint16_t x264_coeff_abs_level_m1_offset[16];
+extern const uint8_t  x264_count_cat_m1[14];
+
+extern const vlc_t x264_coeff0_token[6];
+extern const vlc_t x264_coeff_token[6][16][4];
+extern const vlc_t x264_total_zeros[15][16];
+extern const vlc_t x264_total_zeros_2x2_dc[3][4];
+extern const vlc_t x264_total_zeros_2x4_dc[7][8];
+extern const vlc_t x264_run_before_init[7][16];
+
+#endif
index 639cad42e4873236b1aed18d06d24b6d1efb52a7..7d91ad5677247ba4e48f702c7cb4f7915db74419 100644 (file)
 typedef struct x264_threadpool_t x264_threadpool_t;
 
 #if HAVE_THREAD
+#define x264_threadpool_init x264_template(threadpool_init)
 int   x264_threadpool_init( x264_threadpool_t **p_pool, int threads,
                             void (*init_func)(void *), void *init_arg );
+#define x264_threadpool_run x264_template(threadpool_run)
 void  x264_threadpool_run( x264_threadpool_t *pool, void *(*func)(void *), void *arg );
+#define x264_threadpool_wait x264_template(threadpool_wait)
 void *x264_threadpool_wait( x264_threadpool_t *pool, void *arg );
+#define x264_threadpool_delete x264_template(threadpool_delete)
 void  x264_threadpool_delete( x264_threadpool_t *pool );
 #else
 #define x264_threadpool_init(p,t,f,a) -1
index a55d4b900f2b41c758c27fb8bbfb13cda42a98d1..48954aff0aa6a9b885496d63e1d5a29808077078 100644 (file)
 
 #include "common.h"
 
-/* [nC] */
-const vlc_t x264_coeff0_token[6] =
-{
-    { 0x1, 1 }, /* str=1 */
-    { 0x3, 2 }, /* str=11 */
-    { 0xf, 4 }, /* str=1111 */
-    { 0x3, 6 }, /* str=000011 */
-    { 0x1, 2 }, /* str=01 */
-    { 0x1, 1 }, /* str=1 */
-};
-
-/* [nC][i_total_coeff-1][i_trailing] */
-const vlc_t x264_coeff_token[6][16][4] =
-{
-    { /* table 0 */
-        { /* i_total 1 */
-            { 0x5, 6 }, /* str=000101 */
-            { 0x1, 2 }, /* str=01 */
-        },
-        { /* i_total 2 */
-            { 0x7, 8 }, /* str=00000111 */
-            { 0x4, 6 }, /* str=000100 */
-            { 0x1, 3 }, /* str=001 */
-        },
-        { /* i_total 3 */
-            { 0x7, 9 }, /* str=000000111 */
-            { 0x6, 8 }, /* str=00000110 */
-            { 0x5, 7 }, /* str=0000101 */
-            { 0x3, 5 }, /* str=00011 */
-        },
-        { /* i_total 4 */
-            { 0x7, 10 }, /* str=0000000111 */
-            { 0x6, 9 },  /* str=000000110 */
-            { 0x5, 8 },  /* str=00000101 */
-            { 0x3, 6 },  /* str=000011 */
-        },
-        { /* i_total 5 */
-            { 0x7, 11 }, /* str=00000000111 */
-            { 0x6, 10 }, /* str=0000000110 */
-            { 0x5, 9 },  /* str=000000101 */
-            { 0x4, 7 },  /* str=0000100 */
-        },
-        { /* i_total 6 */
-            { 0xf, 13 }, /* str=0000000001111 */
-            { 0x6, 11 }, /* str=00000000110 */
-            { 0x5, 10 }, /* str=0000000101 */
-            { 0x4, 8 },  /* str=00000100 */
-        },
-        { /* i_total 7 */
-            { 0xb, 13 }, /* str=0000000001011 */
-            { 0xe, 13 }, /* str=0000000001110 */
-            { 0x5, 11 }, /* str=00000000101 */
-            { 0x4, 9 },  /* str=000000100 */
-        },
-        { /* i_total 8 */
-            { 0x8, 13 }, /* str=0000000001000 */
-            { 0xa, 13 }, /* str=0000000001010 */
-            { 0xd, 13 }, /* str=0000000001101 */
-            { 0x4, 10 }, /* str=0000000100 */
-        },
-        { /* i_total 9 */
-            { 0xf, 14 }, /* str=00000000001111 */
-            { 0xe, 14 }, /* str=00000000001110 */
-            { 0x9, 13 }, /* str=0000000001001 */
-            { 0x4, 11 }, /* str=00000000100 */
-        },
-        { /* i_total 10 */
-            { 0xb, 14 }, /* str=00000000001011 */
-            { 0xa, 14 }, /* str=00000000001010 */
-            { 0xd, 14 }, /* str=00000000001101 */
-            { 0xc, 13 }, /* str=0000000001100 */
-        },
-        { /* i_total 14 */
-            { 0xf, 15 }, /* str=000000000001111 */
-            { 0xe, 15 }, /* str=000000000001110 */
-            { 0x9, 14 }, /* str=00000000001001 */
-            { 0xc, 14 }, /* str=00000000001100 */
-        },
-        { /* i_total 12 */
-            { 0xb, 15 }, /* str=000000000001011 */
-            { 0xa, 15 }, /* str=000000000001010 */
-            { 0xd, 15 }, /* str=000000000001101 */
-            { 0x8, 14 }, /* str=00000000001000 */
-        },
-        { /* i_total 13 */
-            { 0xf, 16 }, /* str=0000000000001111 */
-            { 0x1, 15 }, /* str=000000000000001 */
-            { 0x9, 15 }, /* str=000000000001001 */
-            { 0xc, 15 }, /* str=000000000001100 */
-        },
-        { /* i_total 14 */
-            { 0xb, 16 }, /* str=0000000000001011 */
-            { 0xe, 16 }, /* str=0000000000001110 */
-            { 0xd, 16 }, /* str=0000000000001101 */
-            { 0x8, 15 }, /* str=000000000001000 */
-        },
-        { /* i_total 15 */
-            { 0x7, 16 }, /* str=0000000000000111 */
-            { 0xa, 16 }, /* str=0000000000001010 */
-            { 0x9, 16 }, /* str=0000000000001001 */
-            { 0xc, 16 }, /* str=0000000000001100 */
-        },
-        { /* i_total 16 */
-            { 0x4, 16 }, /* str=0000000000000100 */
-            { 0x6, 16 }, /* str=0000000000000110 */
-            { 0x5, 16 }, /* str=0000000000000101 */
-            { 0x8, 16 }, /* str=0000000000001000 */
-        },
-    },
-    { /* table 1 */
-        { /* i_total 1 */
-            { 0xb, 6 }, /* str=001011 */
-            { 0x2, 2 }, /* str=10 */
-        },
-        { /* i_total 2 */
-            { 0x7, 6 }, /* str=000111 */
-            { 0x7, 5 }, /* str=00111 */
-            { 0x3, 3 }, /* str=011 */
-        },
-        { /* i_total 3 */
-            { 0x7, 7 }, /* str=0000111 */
-            { 0xa, 6 }, /* str=001010 */
-            { 0x9, 6 }, /* str=001001 */
-            { 0x5, 4 }, /* str=0101 */
-        },
-        { /* i_total 4 */
-            { 0x7, 8 }, /* str=00000111 */
-            { 0x6, 6 }, /* str=000110 */
-            { 0x5, 6 }, /* str=000101 */
-            { 0x4, 4 }, /* str=0100 */
-        },
-        { /* i_total 5 */
-            { 0x4, 8 }, /* str=00000100 */
-            { 0x6, 7 }, /* str=0000110 */
-            { 0x5, 7 }, /* str=0000101 */
-            { 0x6, 5 }, /* str=00110 */
-        },
-        { /* i_total 6 */
-            { 0x7, 9 }, /* str=000000111 */
-            { 0x6, 8 }, /* str=00000110 */
-            { 0x5, 8 }, /* str=00000101 */
-            { 0x8, 6 }, /* str=001000 */
-        },
-        { /* i_total 7 */
-            { 0xf, 11 }, /* str=00000001111 */
-            { 0x6, 9 },  /* str=000000110 */
-            { 0x5, 9 },  /* str=000000101 */
-            { 0x4, 6 },  /* str=000100 */
-        },
-        { /* i_total 8 */
-            { 0xb, 11 }, /* str=00000001011 */
-            { 0xe, 11 }, /* str=00000001110 */
-            { 0xd, 11 }, /* str=00000001101 */
-            { 0x4, 7 },  /* str=0000100 */
-        },
-        { /* i_total 9 */
-            { 0xf, 12 }, /* str=000000001111 */
-            { 0xa, 11 }, /* str=00000001010 */
-            { 0x9, 11 }, /* str=00000001001 */
-            { 0x4, 9 },  /* str=000000100 */
-        },
-        { /* i_total 10 */
-            { 0xb, 12 }, /* str=000000001011 */
-            { 0xe, 12 }, /* str=000000001110 */
-            { 0xd, 12 }, /* str=000000001101 */
-            { 0xc, 11 }, /* str=00000001100 */
-        },
-        { /* i_total 11 */
-            { 0x8, 12 }, /* str=000000001000 */
-            { 0xa, 12 }, /* str=000000001010 */
-            { 0x9, 12 }, /* str=000000001001 */
-            { 0x8, 11 }, /* str=00000001000 */
-        },
-        { /* i_total 12 */
-            { 0xf, 13 }, /* str=0000000001111 */
-            { 0xe, 13 }, /* str=0000000001110 */
-            { 0xd, 13 }, /* str=0000000001101 */
-            { 0xc, 12 }, /* str=000000001100 */
-        },
-        { /* i_total 13 */
-            { 0xb, 13 }, /* str=0000000001011 */
-            { 0xa, 13 }, /* str=0000000001010 */
-            { 0x9, 13 }, /* str=0000000001001 */
-            { 0xc, 13 }, /* str=0000000001100 */
-        },
-        { /* i_total 14 */
-            { 0x7, 13 }, /* str=0000000000111 */
-            { 0xb, 14 }, /* str=00000000001011 */
-            { 0x6, 13 }, /* str=0000000000110 */
-            { 0x8, 13 }, /* str=0000000001000 */
-        },
-        { /* i_total 15 */
-            { 0x9, 14 }, /* str=00000000001001 */
-            { 0x8, 14 }, /* str=00000000001000 */
-            { 0xa, 14 }, /* str=00000000001010 */
-            { 0x1, 13 }, /* str=0000000000001 */
-        },
-        { /* i_total 16 */
-            { 0x7, 14 }, /* str=00000000000111 */
-            { 0x6, 14 }, /* str=00000000000110 */
-            { 0x5, 14 }, /* str=00000000000101 */
-            { 0x4, 14 }, /* str=00000000000100 */
-        },
-    },
-    { /* table 2 */
-        { /* i_total 1 */
-            { 0xf, 6 }, /* str=001111 */
-            { 0xe, 4 }, /* str=1110 */
-        },
-        { /* i_total 2 */
-            { 0xb, 6 }, /* str=001011 */
-            { 0xf, 5 }, /* str=01111 */
-            { 0xd, 4 }, /* str=1101 */
-        },
-        { /* i_total 3 */
-            { 0x8, 6 }, /* str=001000 */
-            { 0xc, 5 }, /* str=01100 */
-            { 0xe, 5 }, /* str=01110 */
-            { 0xc, 4 }, /* str=1100 */
-        },
-        { /* i_total 4 */
-            { 0xf, 7 }, /* str=0001111 */
-            { 0xa, 5 }, /* str=01010 */
-            { 0xb, 5 }, /* str=01011 */
-            { 0xb, 4 }, /* str=1011 */
-        },
-        { /* i_total 5 */
-            { 0xb, 7 }, /* str=0001011 */
-            { 0x8, 5 }, /* str=01000 */
-            { 0x9, 5 }, /* str=01001 */
-            { 0xa, 4 }, /* str=1010 */
-        },
-        { /* i_total 6 */
-            { 0x9, 7 }, /* str=0001001 */
-            { 0xe, 6 }, /* str=001110 */
-            { 0xd, 6 }, /* str=001101 */
-            { 0x9, 4 }, /* str=1001 */
-        },
-        { /* i_total 7 */
-            { 0x8, 7 }, /* str=0001000 */
-            { 0xa, 6 }, /* str=001010 */
-            { 0x9, 6 }, /* str=001001 */
-            { 0x8, 4 }, /* str=1000 */
-        },
-        { /* i_total 8 */
-            { 0xf, 8 }, /* str=00001111 */
-            { 0xe, 7 }, /* str=0001110 */
-            { 0xd, 7 }, /* str=0001101 */
-            { 0xd, 5 }, /* str=01101 */
-        },
-        { /* i_total 9 */
-            { 0xb, 8 }, /* str=00001011 */
-            { 0xe, 8 }, /* str=00001110 */
-            { 0xa, 7 }, /* str=0001010 */
-            { 0xc, 6 }, /* str=001100 */
-        },
-        { /* i_total 10 */
-            { 0xf, 9 }, /* str=000001111 */
-            { 0xa, 8 }, /* str=00001010 */
-            { 0xd, 8 }, /* str=00001101 */
-            { 0xc, 7 }, /* str=0001100 */
-        },
-        { /* i_total 11 */
-            { 0xb, 9 }, /* str=000001011 */
-            { 0xe, 9 }, /* str=000001110 */
-            { 0x9, 8 }, /* str=00001001 */
-            { 0xc, 8 }, /* str=00001100 */
-        },
-        { /* i_total 12 */
-            { 0x8, 9 }, /* str=000001000 */
-            { 0xa, 9 }, /* str=000001010 */
-            { 0xd, 9 }, /* str=000001101 */
-            { 0x8, 8 }, /* str=00001000 */
-        },
-        { /* i_total 13 */
-            { 0xd, 10 }, /* str=0000001101 */
-            { 0x7, 9 },  /* str=000000111 */
-            { 0x9, 9 },  /* str=000001001 */
-            { 0xc, 9 },  /* str=000001100 */
-        },
-        { /* i_total 14 */
-            { 0x9, 10 }, /* str=0000001001 */
-            { 0xc, 10 }, /* str=0000001100 */
-            { 0xb, 10 }, /* str=0000001011 */
-            { 0xa, 10 }, /* str=0000001010 */
-        },
-        { /* i_total 15 */
-            { 0x5, 10 }, /* str=0000000101 */
-            { 0x8, 10 }, /* str=0000001000 */
-            { 0x7, 10 }, /* str=0000000111 */
-            { 0x6, 10 }, /* str=0000000110 */
-        },
-        { /* i_total 16 */
-            { 0x1, 10 }, /* str=0000000001 */
-            { 0x4, 10 }, /* str=0000000100 */
-            { 0x3, 10 }, /* str=0000000011 */
-            { 0x2, 10 }, /* str=0000000010 */
-        },
-    },
-    { /* table 3 */
-        { /* i_total 1 */
-            { 0x0, 6 }, /* str=000000 */
-            { 0x1, 6 }, /* str=000001 */
-        },
-        { /* i_total 2 */
-            { 0x4, 6 }, /* str=000100 */
-            { 0x5, 6 }, /* str=000101 */
-            { 0x6, 6 }, /* str=000110 */
-        },
-        { /* i_total 3 */
-            { 0x8, 6 }, /* str=001000 */
-            { 0x9, 6 }, /* str=001001 */
-            { 0xa, 6 }, /* str=001010 */
-            { 0xb, 6 }, /* str=001011 */
-        },
-        { /* i_total 4 */
-            { 0xc, 6 }, /* str=001100 */
-            { 0xd, 6 }, /* str=001101 */
-            { 0xe, 6 }, /* str=001110 */
-            { 0xf, 6 }, /* str=001111 */
-        },
-        { /* i_total 5 */
-            { 0x10, 6 }, /* str=010000 */
-            { 0x11, 6 }, /* str=010001 */
-            { 0x12, 6 }, /* str=010010 */
-            { 0x13, 6 }, /* str=010011 */
-        },
-        { /* i_total 6 */
-            { 0x14, 6 }, /* str=010100 */
-            { 0x15, 6 }, /* str=010101 */
-            { 0x16, 6 }, /* str=010110 */
-            { 0x17, 6 }, /* str=010111 */
-        },
-        { /* i_total 7 */
-            { 0x18, 6 }, /* str=011000 */
-            { 0x19, 6 }, /* str=011001 */
-            { 0x1a, 6 }, /* str=011010 */
-            { 0x1b, 6 }, /* str=011011 */
-        },
-        { /* i_total 8 */
-            { 0x1c, 6 }, /* str=011100 */
-            { 0x1d, 6 }, /* str=011101 */
-            { 0x1e, 6 }, /* str=011110 */
-            { 0x1f, 6 }, /* str=011111 */
-        },
-        { /* i_total 9 */
-            { 0x20, 6 }, /* str=100000 */
-            { 0x21, 6 }, /* str=100001 */
-            { 0x22, 6 }, /* str=100010 */
-            { 0x23, 6 }, /* str=100011 */
-        },
-        { /* i_total 10 */
-            { 0x24, 6 }, /* str=100100 */
-            { 0x25, 6 }, /* str=100101 */
-            { 0x26, 6 }, /* str=100110 */
-            { 0x27, 6 }, /* str=100111 */
-        },
-        { /* i_total 11 */
-            { 0x28, 6 }, /* str=101000 */
-            { 0x29, 6 }, /* str=101001 */
-            { 0x2a, 6 }, /* str=101010 */
-            { 0x2b, 6 }, /* str=101011 */
-        },
-        { /* i_total 12 */
-            { 0x2c, 6 }, /* str=101100 */
-            { 0x2d, 6 }, /* str=101101 */
-            { 0x2e, 6 }, /* str=101110 */
-            { 0x2f, 6 }, /* str=101111 */
-        },
-        { /* i_total 13 */
-            { 0x30, 6 }, /* str=110000 */
-            { 0x31, 6 }, /* str=110001 */
-            { 0x32, 6 }, /* str=110010 */
-            { 0x33, 6 }, /* str=110011 */
-        },
-        { /* i_total 14 */
-            { 0x34, 6 }, /* str=110100 */
-            { 0x35, 6 }, /* str=110101 */
-            { 0x36, 6 }, /* str=110110 */
-            { 0x37, 6 }, /* str=110111 */
-        },
-        { /* i_total 15 */
-            { 0x38, 6 }, /* str=111000 */
-            { 0x39, 6 }, /* str=111001 */
-            { 0x3a, 6 }, /* str=111010 */
-            { 0x3b, 6 }, /* str=111011 */
-        },
-        { /* i_total 16 */
-            { 0x3c, 6 }, /* str=111100 */
-            { 0x3d, 6 }, /* str=111101 */
-            { 0x3e, 6 }, /* str=111110 */
-            { 0x3f, 6 }, /* str=111111 */
-        },
-    },
-    { /* table 4 */
-        { /* i_total 1 */
-            { 0x7, 6 }, /* str=000111 */
-            { 0x1, 1 }, /* str=1 */
-        },
-        { /* i_total 2 */
-            { 0x4, 6 }, /* str=000100 */
-            { 0x6, 6 }, /* str=000110 */
-            { 0x1, 3 }, /* str=001 */
-        },
-        { /* i_total 3 */
-            { 0x3, 6 }, /* str=000011 */
-            { 0x3, 7 }, /* str=0000011 */
-            { 0x2, 7 }, /* str=0000010 */
-            { 0x5, 6 }, /* str=000101 */
-        },
-        { /* i_total 4 */
-            { 0x2, 6 }, /* str=000010 */
-            { 0x3, 8 }, /* str=00000011 */
-            { 0x2, 8 }, /* str=00000010 */
-            { 0x0, 7 }, /* str=0000000 */
-        },
-    },
-    { /* table 5 */
-        { /* i_total 1 */
-            { 0xf, 7 }, /* str=0001111 */
-            { 0x1, 2 }, /* str=01 */
-        },
-        { /* i_total 2 */
-            { 0xe, 7 }, /* str=0001110 */
-            { 0xd, 7 }, /* str=0001101 */
-            { 0x1, 3 }, /* str=001 */
-        },
-        { /* i_total 3 */
-            { 0x7, 9 }, /* str=000000111 */
-            { 0xc, 7 }, /* str=0001100 */
-            { 0xb, 7 }, /* str=0001011 */
-            { 0x1, 5 }, /* str=00001 */
-        },
-        { /* i_total 4 */
-            { 0x6, 9 }, /* str=000000110 */
-            { 0x5, 9 }, /* str=000000101 */
-            { 0xa, 7 }, /* str=0001010 */
-            { 0x1, 6 }, /* str=000001 */
-        },
-        { /* i_total 5 */
-            { 0x7, 10 }, /* str=0000000111 */
-            { 0x6, 10 }, /* str=0000000110 */
-            { 0x4, 9 },  /* str=000000100 */
-            { 0x9, 7 },  /* str=0001001 */
-        },
-        { /* i_total 6 */
-            { 0x7, 11 }, /* str=00000000111 */
-            { 0x6, 11 }, /* str=00000000110 */
-            { 0x5, 10 }, /* str=0000000101 */
-            { 0x8, 7 },  /* str=0001000 */
-        },
-        { /* i_total 7 */
-            { 0x7, 12 }, /* str=000000000111 */
-            { 0x6, 12 }, /* str=000000000110 */
-            { 0x5, 11 }, /* str=00000000101 */
-            { 0x4, 10 }, /* str=0000000100 */
-        },
-        { /* i_total 8 */
-            { 0x7, 13 }, /* str=0000000000111 */
-            { 0x5, 12 }, /* str=000000000101 */
-            { 0x4, 12 }, /* str=000000000100 */
-            { 0x4, 11 }, /* str=00000000100 */
-        },
-    },
-};
-
-/* [i_total_coeff-1][i_total_zeros] */
-const vlc_t x264_total_zeros[15][16] =
-{
-    { /* i_total 1 */
-        { 0x1, 1 }, /* str=1 */
-        { 0x3, 3 }, /* str=011 */
-        { 0x2, 3 }, /* str=010 */
-        { 0x3, 4 }, /* str=0011 */
-        { 0x2, 4 }, /* str=0010 */
-        { 0x3, 5 }, /* str=00011 */
-        { 0x2, 5 }, /* str=00010 */
-        { 0x3, 6 }, /* str=000011 */
-        { 0x2, 6 }, /* str=000010 */
-        { 0x3, 7 }, /* str=0000011 */
-        { 0x2, 7 }, /* str=0000010 */
-        { 0x3, 8 }, /* str=00000011 */
-        { 0x2, 8 }, /* str=00000010 */
-        { 0x3, 9 }, /* str=000000011 */
-        { 0x2, 9 }, /* str=000000010 */
-        { 0x1, 9 }, /* str=000000001 */
-    },
-    { /* i_total 2 */
-        { 0x7, 3 }, /* str=111 */
-        { 0x6, 3 }, /* str=110 */
-        { 0x5, 3 }, /* str=101 */
-        { 0x4, 3 }, /* str=100 */
-        { 0x3, 3 }, /* str=011 */
-        { 0x5, 4 }, /* str=0101 */
-        { 0x4, 4 }, /* str=0100 */
-        { 0x3, 4 }, /* str=0011 */
-        { 0x2, 4 }, /* str=0010 */
-        { 0x3, 5 }, /* str=00011 */
-        { 0x2, 5 }, /* str=00010 */
-        { 0x3, 6 }, /* str=000011 */
-        { 0x2, 6 }, /* str=000010 */
-        { 0x1, 6 }, /* str=000001 */
-        { 0x0, 6 }, /* str=000000 */
-    },
-    { /* i_total 3 */
-        { 0x5, 4 }, /* str=0101 */
-        { 0x7, 3 }, /* str=111 */
-        { 0x6, 3 }, /* str=110 */
-        { 0x5, 3 }, /* str=101 */
-        { 0x4, 4 }, /* str=0100 */
-        { 0x3, 4 }, /* str=0011 */
-        { 0x4, 3 }, /* str=100 */
-        { 0x3, 3 }, /* str=011 */
-        { 0x2, 4 }, /* str=0010 */
-        { 0x3, 5 }, /* str=00011 */
-        { 0x2, 5 }, /* str=00010 */
-        { 0x1, 6 }, /* str=000001 */
-        { 0x1, 5 }, /* str=00001 */
-        { 0x0, 6 }, /* str=000000 */
-    },
-    { /* i_total 4 */
-        { 0x3, 5 }, /* str=00011 */
-        { 0x7, 3 }, /* str=111 */
-        { 0x5, 4 }, /* str=0101 */
-        { 0x4, 4 }, /* str=0100 */
-        { 0x6, 3 }, /* str=110 */
-        { 0x5, 3 }, /* str=101 */
-        { 0x4, 3 }, /* str=100 */
-        { 0x3, 4 }, /* str=0011 */
-        { 0x3, 3 }, /* str=011 */
-        { 0x2, 4 }, /* str=0010 */
-        { 0x2, 5 }, /* str=00010 */
-        { 0x1, 5 }, /* str=00001 */
-        { 0x0, 5 }, /* str=00000 */
-    },
-    { /* i_total 5 */
-        { 0x5, 4 }, /* str=0101 */
-        { 0x4, 4 }, /* str=0100 */
-        { 0x3, 4 }, /* str=0011 */
-        { 0x7, 3 }, /* str=111 */
-        { 0x6, 3 }, /* str=110 */
-        { 0x5, 3 }, /* str=101 */
-        { 0x4, 3 }, /* str=100 */
-        { 0x3, 3 }, /* str=011 */
-        { 0x2, 4 }, /* str=0010 */
-        { 0x1, 5 }, /* str=00001 */
-        { 0x1, 4 }, /* str=0001 */
-        { 0x0, 5 }, /* str=00000 */
-    },
-    { /* i_total 6 */
-        { 0x1, 6 }, /* str=000001 */
-        { 0x1, 5 }, /* str=00001 */
-        { 0x7, 3 }, /* str=111 */
-        { 0x6, 3 }, /* str=110 */
-        { 0x5, 3 }, /* str=101 */
-        { 0x4, 3 }, /* str=100 */
-        { 0x3, 3 }, /* str=011 */
-        { 0x2, 3 }, /* str=010 */
-        { 0x1, 4 }, /* str=0001 */
-        { 0x1, 3 }, /* str=001 */
-        { 0x0, 6 }, /* str=000000 */
-    },
-    { /* i_total 7 */
-        { 0x1, 6 }, /* str=000001 */
-        { 0x1, 5 }, /* str=00001 */
-        { 0x5, 3 }, /* str=101 */
-        { 0x4, 3 }, /* str=100 */
-        { 0x3, 3 }, /* str=011 */
-        { 0x3, 2 }, /* str=11 */
-        { 0x2, 3 }, /* str=010 */
-        { 0x1, 4 }, /* str=0001 */
-        { 0x1, 3 }, /* str=001 */
-        { 0x0, 6 }, /* str=000000 */
-    },
-    { /* i_total 8 */
-        { 0x1, 6 }, /* str=000001 */
-        { 0x1, 4 }, /* str=0001 */
-        { 0x1, 5 }, /* str=00001 */
-        { 0x3, 3 }, /* str=011 */
-        { 0x3, 2 }, /* str=11 */
-        { 0x2, 2 }, /* str=10 */
-        { 0x2, 3 }, /* str=010 */
-        { 0x1, 3 }, /* str=001 */
-        { 0x0, 6 }, /* str=000000 */
-    },
-    { /* i_total 9 */
-        { 0x1, 6 }, /* str=000001 */
-        { 0x0, 6 }, /* str=000000 */
-        { 0x1, 4 }, /* str=0001 */
-        { 0x3, 2 }, /* str=11 */
-        { 0x2, 2 }, /* str=10 */
-        { 0x1, 3 }, /* str=001 */
-        { 0x1, 2 }, /* str=01 */
-        { 0x1, 5 }, /* str=00001 */
-    },
-    { /* i_total 10 */
-        { 0x1, 5 }, /* str=00001 */
-        { 0x0, 5 }, /* str=00000 */
-        { 0x1, 3 }, /* str=001 */
-        { 0x3, 2 }, /* str=11 */
-        { 0x2, 2 }, /* str=10 */
-        { 0x1, 2 }, /* str=01 */
-        { 0x1, 4 }, /* str=0001 */
-    },
-    { /* i_total 11 */
-        { 0x0, 4 }, /* str=0000 */
-        { 0x1, 4 }, /* str=0001 */
-        { 0x1, 3 }, /* str=001 */
-        { 0x2, 3 }, /* str=010 */
-        { 0x1, 1 }, /* str=1 */
-        { 0x3, 3 }, /* str=011 */
-    },
-    { /* i_total 12 */
-        { 0x0, 4 }, /* str=0000 */
-        { 0x1, 4 }, /* str=0001 */
-        { 0x1, 2 }, /* str=01 */
-        { 0x1, 1 }, /* str=1 */
-        { 0x1, 3 }, /* str=001 */
-    },
-    { /* i_total 13 */
-        { 0x0, 3 }, /* str=000 */
-        { 0x1, 3 }, /* str=001 */
-        { 0x1, 1 }, /* str=1 */
-        { 0x1, 2 }, /* str=01 */
-    },
-    { /* i_total 14 */
-        { 0x0, 2 }, /* str=00 */
-        { 0x1, 2 }, /* str=01 */
-        { 0x1, 1 }, /* str=1 */
-    },
-    { /* i_total 15 */
-        { 0x0, 1 }, /* str=0 */
-        { 0x1, 1 }, /* str=1 */
-    },
-};
-
-/* [i_total_coeff-1][i_total_zeros] */
-const vlc_t x264_total_zeros_2x2_dc[3][4] =
-{
-    { /* i_total 1 */
-        { 0x1, 1 }, /* str=1 */
-        { 0x1, 2 }, /* str=01 */
-        { 0x1, 3 }, /* str=001 */
-        { 0x0, 3 }  /* str=000 */
-    },
-    { /* i_total 2 */
-        { 0x1, 1 }, /* str=1 */
-        { 0x1, 2 }, /* str=01 */
-        { 0x0, 2 }, /* str=00 */
-    },
-    { /* i_total 3 */
-        { 0x1, 1 }, /* str=1 */
-        { 0x0, 1 }, /* str=0 */
-    },
-};
-
-/* [i_total_coeff-1][i_total_zeros] */
-const vlc_t x264_total_zeros_2x4_dc[7][8] =
-{
-    { /* i_total 1 */
-        { 0x1, 1 }, /* str=1 */
-        { 0x2, 3 }, /* str=010 */
-        { 0x3, 3 }, /* str=011 */
-        { 0x2, 4 }, /* str=0010 */
-        { 0x3, 4 }, /* str=0011 */
-        { 0x1, 4 }, /* str=0001 */
-        { 0x1, 5 }, /* str=00001 */
-        { 0x0, 5 }, /* str=00000 */
-    },
-    { /* i_total 2 */
-        { 0x0, 3 }, /* str=000 */
-        { 0x1, 2 }, /* str=01 */
-        { 0x1, 3 }, /* str=001 */
-        { 0x4, 3 }, /* str=100 */
-        { 0x5, 3 }, /* str=101 */
-        { 0x6, 3 }, /* str=110 */
-        { 0x7, 3 }, /* str=111 */
-    },
-    { /* i_total 3 */
-        { 0x0, 3 }, /* str=000 */
-        { 0x1, 3 }, /* str=001 */
-        { 0x1, 2 }, /* str=01 */
-        { 0x2, 2 }, /* str=10 */
-        { 0x6, 3 }, /* str=110 */
-        { 0x7, 3 }, /* str=111 */
-    },
-    { /* i_total 4 */
-        { 0x6, 3 }, /* str=110 */
-        { 0x0, 2 }, /* str=00 */
-        { 0x1, 2 }, /* str=01 */
-        { 0x2, 2 }, /* str=10 */
-        { 0x7, 3 }, /* str=111 */
-    },
-    { /* i_total 5 */
-        { 0x0, 2 }, /* str=00 */
-        { 0x1, 2 }, /* str=01 */
-        { 0x2, 2 }, /* str=10 */
-        { 0x3, 2 }, /* str=11 */
-    },
-    { /* i_total 6 */
-        { 0x0, 2 }, /* str=00 */
-        { 0x1, 2 }, /* str=01 */
-        { 0x1, 1 }, /* str=1 */
-    },
-    { /* i_total 7 */
-        { 0x0, 1 }, /* str=0 */
-        { 0x1, 1 }, /* str=1 */
-    }
-};
-
-/* [MIN( i_zero_left-1, 6 )][run_before] */
-static const vlc_t run_before[7][16] =
-{
-    { /* i_zero_left 1 */
-        { 0x1, 1 }, /* str=1 */
-        { 0x0, 1 }, /* str=0 */
-    },
-    { /* i_zero_left 2 */
-        { 0x1, 1 }, /* str=1 */
-        { 0x1, 2 }, /* str=01 */
-        { 0x0, 2 }, /* str=00 */
-    },
-    { /* i_zero_left 3 */
-        { 0x3, 2 }, /* str=11 */
-        { 0x2, 2 }, /* str=10 */
-        { 0x1, 2 }, /* str=01 */
-        { 0x0, 2 }, /* str=00 */
-    },
-    { /* i_zero_left 4 */
-        { 0x3, 2 }, /* str=11 */
-        { 0x2, 2 }, /* str=10 */
-        { 0x1, 2 }, /* str=01 */
-        { 0x1, 3 }, /* str=001 */
-        { 0x0, 3 }, /* str=000 */
-    },
-    { /* i_zero_left 5 */
-        { 0x3, 2 }, /* str=11 */
-        { 0x2, 2 }, /* str=10 */
-        { 0x3, 3 }, /* str=011 */
-        { 0x2, 3 }, /* str=010 */
-        { 0x1, 3 }, /* str=001 */
-        { 0x0, 3 }, /* str=000 */
-    },
-    { /* i_zero_left 6 */
-        { 0x3, 2 }, /* str=11 */
-        { 0x0, 3 }, /* str=000 */
-        { 0x1, 3 }, /* str=001 */
-        { 0x3, 3 }, /* str=011 */
-        { 0x2, 3 }, /* str=010 */
-        { 0x5, 3 }, /* str=101 */
-        { 0x4, 3 }, /* str=100 */
-    },
-    { /* i_zero_left >6 */
-        { 0x7, 3 }, /* str=111 */
-        { 0x6, 3 }, /* str=110 */
-        { 0x5, 3 }, /* str=101 */
-        { 0x4, 3 }, /* str=100 */
-        { 0x3, 3 }, /* str=011 */
-        { 0x2, 3 }, /* str=010 */
-        { 0x1, 3 }, /* str=001 */
-        { 0x1, 4 }, /* str=0001 */
-        { 0x1, 5 }, /* str=00001 */
-        { 0x1, 6 }, /* str=000001 */
-        { 0x1, 7 }, /* str=0000001 */
-        { 0x1, 8 }, /* str=00000001 */
-        { 0x1, 9 }, /* str=000000001 */
-        { 0x1, 10 }, /* str=0000000001 */
-        { 0x1, 11 }, /* str=00000000001 */
-    },
-};
-
 vlc_large_t x264_level_token[7][LEVEL_TABLE_SIZE];
 uint32_t x264_run_before[1<<16];
 
@@ -857,10 +86,10 @@ void x264_cavlc_init( x264_t *h )
         {
             int idx = X264_MIN(zeros, 7) - 1;
             int run = x264_clz( mask );
-            int len = run_before[idx][run].i_size;
+            int len = x264_run_before_init[idx][run].i_size;
             size += len;
             bits <<= len;
-            bits |= run_before[idx][run].i_bits;
+            bits |= x264_run_before_init[idx][run].i_bits;
             zeros -= run;
             mask <<= run + 1;
         }
index 8f878d94277224ada946bf50ad2c7b426436fa35..d12f16e7e6c4f680bc35c7cd029d25e1f97ad713 100644 (file)
@@ -31,7 +31,7 @@
 /* Based on the agreed standing that x264 does not need to utilize >64 logical cpus,
  * this API does not detect nor utilize more than 64 cpus for systems that have them. */
 
-#include "common.h"
+#include "base.h"
 
 #if HAVE_WINRT
 /* _beginthreadex() is technically the correct option, but it's only available for Desktop applications.
diff --git a/common/x86/bitstream.h b/common/x86/bitstream.h
new file mode 100644 (file)
index 0000000..579a0e9
--- /dev/null
@@ -0,0 +1,64 @@
+/*****************************************************************************
+ * bitstream.h: x86 bitstream functions
+ *****************************************************************************
+ * Copyright (C) 2017 x264 project
+ *
+ * Authors: Anton Mitrofanov <BugMaster@narod.ru>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@x264.com.
+ *****************************************************************************/
+
+#ifndef X264_X86_BITSTREAM_H
+#define X264_X86_BITSTREAM_H
+
+#define x264_nal_escape_mmx2 x264_template(nal_escape_mmx2)
+uint8_t *x264_nal_escape_mmx2( uint8_t *dst, uint8_t *src, uint8_t *end );
+#define x264_nal_escape_sse2 x264_template(nal_escape_sse2)
+uint8_t *x264_nal_escape_sse2( uint8_t *dst, uint8_t *src, uint8_t *end );
+#define x264_nal_escape_avx2 x264_template(nal_escape_avx2)
+uint8_t *x264_nal_escape_avx2( uint8_t *dst, uint8_t *src, uint8_t *end );
+#define x264_cabac_block_residual_rd_internal_sse2 x264_template(cabac_block_residual_rd_internal_sse2)
+void x264_cabac_block_residual_rd_internal_sse2       ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
+#define x264_cabac_block_residual_rd_internal_lzcnt x264_template(cabac_block_residual_rd_internal_lzcnt)
+void x264_cabac_block_residual_rd_internal_lzcnt      ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
+#define x264_cabac_block_residual_rd_internal_ssse3 x264_template(cabac_block_residual_rd_internal_ssse3)
+void x264_cabac_block_residual_rd_internal_ssse3      ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
+#define x264_cabac_block_residual_rd_internal_ssse3_lzcnt x264_template(cabac_block_residual_rd_internal_ssse3_lzcnt)
+void x264_cabac_block_residual_rd_internal_ssse3_lzcnt( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
+#define x264_cabac_block_residual_rd_internal_avx512 x264_template(cabac_block_residual_rd_internal_avx512)
+void x264_cabac_block_residual_rd_internal_avx512     ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
+#define x264_cabac_block_residual_8x8_rd_internal_sse2 x264_template(cabac_block_residual_8x8_rd_internal_sse2)
+void x264_cabac_block_residual_8x8_rd_internal_sse2       ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
+#define x264_cabac_block_residual_8x8_rd_internal_lzcnt x264_template(cabac_block_residual_8x8_rd_internal_lzcnt)
+void x264_cabac_block_residual_8x8_rd_internal_lzcnt      ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
+#define x264_cabac_block_residual_8x8_rd_internal_ssse3 x264_template(cabac_block_residual_8x8_rd_internal_ssse3)
+void x264_cabac_block_residual_8x8_rd_internal_ssse3      ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
+#define x264_cabac_block_residual_8x8_rd_internal_ssse3_lzcnt x264_template(cabac_block_residual_8x8_rd_internal_ssse3_lzcnt)
+void x264_cabac_block_residual_8x8_rd_internal_ssse3_lzcnt( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
+#define x264_cabac_block_residual_8x8_rd_internal_avx512 x264_template(cabac_block_residual_8x8_rd_internal_avx512)
+void x264_cabac_block_residual_8x8_rd_internal_avx512     ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
+#define x264_cabac_block_residual_internal_sse2 x264_template(cabac_block_residual_internal_sse2)
+void x264_cabac_block_residual_internal_sse2  ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
+#define x264_cabac_block_residual_internal_lzcnt x264_template(cabac_block_residual_internal_lzcnt)
+void x264_cabac_block_residual_internal_lzcnt ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
+#define x264_cabac_block_residual_internal_avx2 x264_template(cabac_block_residual_internal_avx2)
+void x264_cabac_block_residual_internal_avx2  ( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
+#define x264_cabac_block_residual_internal_avx512 x264_template(cabac_block_residual_internal_avx512)
+void x264_cabac_block_residual_internal_avx512( dctcoef *l, int b_interlaced, intptr_t ctx_block_cat, x264_cabac_t *cb );
+
+#endif
index 58448f1e60d8c976894624a52ed070253508810e..39389495323872a7f19a11f87352c1132d7a8fe5 100644 (file)
@@ -87,18 +87,18 @@ coeff_abs_level_transition: db 1, 2, 3, 3, 4, 5, 6, 7
 
 SECTION .text
 
-cextern cabac_range_lps
-cextern cabac_transition
-cextern cabac_renorm_shift
-cextern cabac_entropy
+cextern_common cabac_range_lps
+cextern_common cabac_transition
+cextern_common cabac_renorm_shift
+cextern_common cabac_entropy
 cextern cabac_size_unary
 cextern cabac_transition_unary
-cextern significant_coeff_flag_offset
-cextern significant_coeff_flag_offset_8x8
-cextern last_coeff_flag_offset
-cextern last_coeff_flag_offset_8x8
-cextern coeff_abs_level_m1_offset
-cextern count_cat_m1
+cextern_common significant_coeff_flag_offset
+cextern_common significant_coeff_flag_offset_8x8
+cextern_common last_coeff_flag_offset
+cextern_common last_coeff_flag_offset_8x8
+cextern_common coeff_abs_level_m1_offset
+cextern_common count_cat_m1
 cextern cabac_encode_ue_bypass
 
 %if ARCH_X86_64
index 20a65c53aed74d5171ca773f9cc9bc5375c40b5f..a90a374de7207478e15ca6ef3f2274db17625aef 100644 (file)
 #ifndef X264_I386_DCT_H
 #define X264_I386_DCT_H
 
+#define x264_sub4x4_dct_mmx x264_template(sub4x4_dct_mmx)
 void x264_sub4x4_dct_mmx    ( dctcoef dct    [16], pixel   *pix1, pixel   *pix2 );
+#define x264_sub8x8_dct_mmx x264_template(sub8x8_dct_mmx)
 void x264_sub8x8_dct_mmx    ( dctcoef dct[ 4][16], pixel   *pix1, pixel   *pix2 );
+#define x264_sub16x16_dct_mmx x264_template(sub16x16_dct_mmx)
 void x264_sub16x16_dct_mmx  ( dctcoef dct[16][16], pixel   *pix1, pixel   *pix2 );
+#define x264_sub8x8_dct_sse2 x264_template(sub8x8_dct_sse2)
 void x264_sub8x8_dct_sse2   ( int16_t dct[ 4][16], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub16x16_dct_sse2 x264_template(sub16x16_dct_sse2)
 void x264_sub16x16_dct_sse2 ( int16_t dct[16][16], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub4x4_dct_ssse3 x264_template(sub4x4_dct_ssse3)
 void x264_sub4x4_dct_ssse3  ( int16_t dct    [16], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub4x4_dct_avx512 x264_template(sub4x4_dct_avx512)
 void x264_sub4x4_dct_avx512 ( int16_t dct    [16], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub8x8_dct_ssse3 x264_template(sub8x8_dct_ssse3)
 void x264_sub8x8_dct_ssse3  ( int16_t dct[ 4][16], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub16x16_dct_ssse3 x264_template(sub16x16_dct_ssse3)
 void x264_sub16x16_dct_ssse3( int16_t dct[16][16], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub8x8_dct_avx x264_template(sub8x8_dct_avx)
 void x264_sub8x8_dct_avx    ( int16_t dct[ 4][16], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub16x16_dct_avx x264_template(sub16x16_dct_avx)
 void x264_sub16x16_dct_avx  ( int16_t dct[16][16], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub8x8_dct_xop x264_template(sub8x8_dct_xop)
 void x264_sub8x8_dct_xop    ( int16_t dct[ 4][16], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub16x16_dct_xop x264_template(sub16x16_dct_xop)
 void x264_sub16x16_dct_xop  ( int16_t dct[16][16], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub8x8_dct_avx2 x264_template(sub8x8_dct_avx2)
 void x264_sub8x8_dct_avx2   ( int16_t dct[ 4][16], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub8x8_dct_avx512 x264_template(sub8x8_dct_avx512)
 void x264_sub8x8_dct_avx512 ( int16_t dct[ 4][16], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub16x16_dct_avx2 x264_template(sub16x16_dct_avx2)
 void x264_sub16x16_dct_avx2 ( int16_t dct[16][16], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub16x16_dct_avx512 x264_template(sub16x16_dct_avx512)
 void x264_sub16x16_dct_avx512( int16_t dct[16][16], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub8x8_dct_dc_mmx2 x264_template(sub8x8_dct_dc_mmx2)
 void x264_sub8x8_dct_dc_mmx2   ( int16_t dct [ 4], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub8x8_dct_dc_sse2 x264_template(sub8x8_dct_dc_sse2)
 void x264_sub8x8_dct_dc_sse2   ( dctcoef dct [ 4], pixel   *pix1, pixel   *pix2 );
+#define x264_sub8x8_dct_dc_avx512 x264_template(sub8x8_dct_dc_avx512)
 void x264_sub8x8_dct_dc_avx512 ( int16_t dct [ 4], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub8x16_dct_dc_sse2 x264_template(sub8x16_dct_dc_sse2)
 void x264_sub8x16_dct_dc_sse2  ( dctcoef dct [ 8], pixel   *pix1, pixel   *pix2 );
+#define x264_sub8x16_dct_dc_ssse3 x264_template(sub8x16_dct_dc_ssse3)
 void x264_sub8x16_dct_dc_ssse3 ( int16_t dct [ 8], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub8x16_dct_dc_avx x264_template(sub8x16_dct_dc_avx)
 void x264_sub8x16_dct_dc_avx   ( dctcoef dct [ 8], pixel   *pix1, pixel   *pix2 );
+#define x264_sub8x16_dct_dc_avx512 x264_template(sub8x16_dct_dc_avx512)
 void x264_sub8x16_dct_dc_avx512( int16_t dct [ 8], uint8_t *pix1, uint8_t *pix2 );
 
+#define x264_add4x4_idct_mmx x264_template(add4x4_idct_mmx)
 void x264_add4x4_idct_mmx       ( uint8_t *p_dst, int16_t dct    [16] );
+#define x264_add4x4_idct_sse2 x264_template(add4x4_idct_sse2)
 void x264_add4x4_idct_sse2     ( uint16_t *p_dst, int32_t dct    [16] );
+#define x264_add4x4_idct_sse4 x264_template(add4x4_idct_sse4)
 void x264_add4x4_idct_sse4      ( uint8_t *p_dst, int16_t dct    [16] );
+#define x264_add4x4_idct_avx x264_template(add4x4_idct_avx)
 void x264_add4x4_idct_avx       ( pixel   *p_dst, dctcoef dct    [16] );
+#define x264_add8x8_idct_mmx x264_template(add8x8_idct_mmx)
 void x264_add8x8_idct_mmx       ( uint8_t *p_dst, int16_t dct[ 4][16] );
+#define x264_add8x8_idct_dc_mmx2 x264_template(add8x8_idct_dc_mmx2)
 void x264_add8x8_idct_dc_mmx2   ( uint8_t *p_dst, int16_t dct    [ 4] );
+#define x264_add16x16_idct_mmx x264_template(add16x16_idct_mmx)
 void x264_add16x16_idct_mmx     ( uint8_t *p_dst, int16_t dct[16][16] );
+#define x264_add16x16_idct_dc_mmx2 x264_template(add16x16_idct_dc_mmx2)
 void x264_add16x16_idct_dc_mmx2 ( uint8_t *p_dst, int16_t dct    [16] );
+#define x264_add8x8_idct_sse2 x264_template(add8x8_idct_sse2)
 void x264_add8x8_idct_sse2      ( pixel   *p_dst, dctcoef dct[ 4][16] );
+#define x264_add8x8_idct_avx x264_template(add8x8_idct_avx)
 void x264_add8x8_idct_avx       ( pixel   *p_dst, dctcoef dct[ 4][16] );
+#define x264_add8x8_idct_avx2 x264_template(add8x8_idct_avx2)
 void x264_add8x8_idct_avx2      ( pixel   *p_dst, dctcoef dct[ 4][16] );
+#define x264_add8x8_idct_avx512 x264_template(add8x8_idct_avx512)
 void x264_add8x8_idct_avx512    ( uint8_t *p_dst, int16_t dct[ 4][16] );
+#define x264_add16x16_idct_sse2 x264_template(add16x16_idct_sse2)
 void x264_add16x16_idct_sse2    ( pixel   *p_dst, dctcoef dct[16][16] );
+#define x264_add16x16_idct_avx x264_template(add16x16_idct_avx)
 void x264_add16x16_idct_avx     ( pixel   *p_dst, dctcoef dct[16][16] );
+#define x264_add16x16_idct_avx2 x264_template(add16x16_idct_avx2)
 void x264_add16x16_idct_avx2    ( pixel   *p_dst, dctcoef dct[16][16] );
+#define x264_add8x8_idct_dc_sse2 x264_template(add8x8_idct_dc_sse2)
 void x264_add8x8_idct_dc_sse2   ( pixel   *p_dst, dctcoef dct    [ 4] );
+#define x264_add16x16_idct_dc_sse2 x264_template(add16x16_idct_dc_sse2)
 void x264_add16x16_idct_dc_sse2 ( pixel   *p_dst, dctcoef dct    [16] );
+#define x264_add8x8_idct_dc_ssse3 x264_template(add8x8_idct_dc_ssse3)
 void x264_add8x8_idct_dc_ssse3  ( uint8_t *p_dst, int16_t dct    [ 4] );
+#define x264_add16x16_idct_dc_ssse3 x264_template(add16x16_idct_dc_ssse3)
 void x264_add16x16_idct_dc_ssse3( uint8_t *p_dst, int16_t dct    [16] );
+#define x264_add8x8_idct_dc_avx x264_template(add8x8_idct_dc_avx)
 void x264_add8x8_idct_dc_avx    ( pixel   *p_dst, dctcoef dct    [ 4] );
+#define x264_add16x16_idct_dc_avx x264_template(add16x16_idct_dc_avx)
 void x264_add16x16_idct_dc_avx  ( pixel   *p_dst, dctcoef dct    [16] );
+#define x264_add16x16_idct_dc_avx2 x264_template(add16x16_idct_dc_avx2)
 void x264_add16x16_idct_dc_avx2 ( uint8_t *p_dst, int16_t dct    [16] );
 
+#define x264_dct4x4dc_mmx2 x264_template(dct4x4dc_mmx2)
 void x264_dct4x4dc_mmx2      ( int16_t d[16] );
+#define x264_dct4x4dc_sse2 x264_template(dct4x4dc_sse2)
 void x264_dct4x4dc_sse2      ( int32_t d[16] );
+#define x264_dct4x4dc_avx x264_template(dct4x4dc_avx)
 void x264_dct4x4dc_avx       ( int32_t d[16] );
+#define x264_idct4x4dc_mmx x264_template(idct4x4dc_mmx)
 void x264_idct4x4dc_mmx      ( int16_t d[16] );
+#define x264_idct4x4dc_sse2 x264_template(idct4x4dc_sse2)
 void x264_idct4x4dc_sse2     ( int32_t d[16] );
+#define x264_idct4x4dc_avx x264_template(idct4x4dc_avx)
 void x264_idct4x4dc_avx      ( int32_t d[16] );
 
+#define x264_dct2x4dc_mmx2 x264_template(dct2x4dc_mmx2)
 void x264_dct2x4dc_mmx2( dctcoef dct[8], dctcoef dct4x4[8][16] );
+#define x264_dct2x4dc_sse2 x264_template(dct2x4dc_sse2)
 void x264_dct2x4dc_sse2( dctcoef dct[8], dctcoef dct4x4[8][16] );
+#define x264_dct2x4dc_avx x264_template(dct2x4dc_avx)
 void x264_dct2x4dc_avx ( dctcoef dct[8], dctcoef dct4x4[8][16] );
 
+#define x264_sub8x8_dct8_mmx x264_template(sub8x8_dct8_mmx)
 void x264_sub8x8_dct8_mmx    ( int16_t dct   [64], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub16x16_dct8_mmx x264_template(sub16x16_dct8_mmx)
 void x264_sub16x16_dct8_mmx  ( int16_t dct[4][64], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub8x8_dct8_sse2 x264_template(sub8x8_dct8_sse2)
 void x264_sub8x8_dct8_sse2   ( dctcoef dct   [64], pixel *pix1, pixel *pix2 );
+#define x264_sub16x16_dct8_sse2 x264_template(sub16x16_dct8_sse2)
 void x264_sub16x16_dct8_sse2 ( dctcoef dct[4][64], pixel *pix1, pixel *pix2 );
+#define x264_sub8x8_dct8_ssse3 x264_template(sub8x8_dct8_ssse3)
 void x264_sub8x8_dct8_ssse3  ( int16_t dct   [64], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub16x16_dct8_ssse3 x264_template(sub16x16_dct8_ssse3)
 void x264_sub16x16_dct8_ssse3( int16_t dct[4][64], uint8_t *pix1, uint8_t *pix2 );
+#define x264_sub8x8_dct8_sse4 x264_template(sub8x8_dct8_sse4)
 void x264_sub8x8_dct8_sse4   ( int32_t dct   [64], uint16_t *pix1, uint16_t *pix2 );
+#define x264_sub16x16_dct8_sse4 x264_template(sub16x16_dct8_sse4)
 void x264_sub16x16_dct8_sse4 ( int32_t dct[4][64], uint16_t *pix1, uint16_t *pix2 );
+#define x264_sub8x8_dct8_avx x264_template(sub8x8_dct8_avx)
 void x264_sub8x8_dct8_avx    ( dctcoef dct   [64], pixel *pix1, pixel *pix2 );
+#define x264_sub16x16_dct8_avx x264_template(sub16x16_dct8_avx)
 void x264_sub16x16_dct8_avx  ( dctcoef dct[4][64], pixel *pix1, pixel *pix2 );
+#define x264_sub16x16_dct8_avx2 x264_template(sub16x16_dct8_avx2)
 void x264_sub16x16_dct8_avx2 ( dctcoef dct[4][64], pixel *pix1, pixel *pix2 );
 
 
+#define x264_add8x8_idct8_mmx x264_template(add8x8_idct8_mmx)
 void x264_add8x8_idct8_mmx   ( uint8_t *dst, int16_t dct   [64] );
+#define x264_add16x16_idct8_mmx x264_template(add16x16_idct8_mmx)
 void x264_add16x16_idct8_mmx ( uint8_t *dst, int16_t dct[4][64] );
+#define x264_add8x8_idct8_sse2 x264_template(add8x8_idct8_sse2)
 void x264_add8x8_idct8_sse2  ( pixel *dst, dctcoef dct   [64] );
+#define x264_add16x16_idct8_sse2 x264_template(add16x16_idct8_sse2)
 void x264_add16x16_idct8_sse2( pixel *dst, dctcoef dct[4][64] );
+#define x264_add8x8_idct8_avx x264_template(add8x8_idct8_avx)
 void x264_add8x8_idct8_avx   ( pixel *dst, dctcoef dct   [64] );
+#define x264_add16x16_idct8_avx x264_template(add16x16_idct8_avx)
 void x264_add16x16_idct8_avx ( pixel *dst, dctcoef dct[4][64] );
 
+#define x264_zigzag_scan_8x8_frame_mmx2 x264_template(zigzag_scan_8x8_frame_mmx2)
 void x264_zigzag_scan_8x8_frame_mmx2  ( int16_t level[64], int16_t dct[64] );
+#define x264_zigzag_scan_8x8_frame_sse2 x264_template(zigzag_scan_8x8_frame_sse2)
 void x264_zigzag_scan_8x8_frame_sse2  ( dctcoef level[64], dctcoef dct[64] );
+#define x264_zigzag_scan_8x8_frame_ssse3 x264_template(zigzag_scan_8x8_frame_ssse3)
 void x264_zigzag_scan_8x8_frame_ssse3 ( int16_t level[64], int16_t dct[64] );
+#define x264_zigzag_scan_8x8_frame_avx x264_template(zigzag_scan_8x8_frame_avx)
 void x264_zigzag_scan_8x8_frame_avx   ( dctcoef level[64], dctcoef dct[64] );
+#define x264_zigzag_scan_8x8_frame_xop x264_template(zigzag_scan_8x8_frame_xop)
 void x264_zigzag_scan_8x8_frame_xop   ( int16_t level[64], int16_t dct[64] );
+#define x264_zigzag_scan_8x8_frame_avx512 x264_template(zigzag_scan_8x8_frame_avx512)
 void x264_zigzag_scan_8x8_frame_avx512( dctcoef level[64], dctcoef dct[64] );
+#define x264_zigzag_scan_4x4_frame_mmx x264_template(zigzag_scan_4x4_frame_mmx)
 void x264_zigzag_scan_4x4_frame_mmx   ( int16_t level[16], int16_t dct[16] );
+#define x264_zigzag_scan_4x4_frame_sse2 x264_template(zigzag_scan_4x4_frame_sse2)
 void x264_zigzag_scan_4x4_frame_sse2  ( int32_t level[16], int32_t dct[16] );
+#define x264_zigzag_scan_4x4_frame_ssse3 x264_template(zigzag_scan_4x4_frame_ssse3)
 void x264_zigzag_scan_4x4_frame_ssse3 ( int16_t level[16], int16_t dct[16] );
+#define x264_zigzag_scan_4x4_frame_avx x264_template(zigzag_scan_4x4_frame_avx)
 void x264_zigzag_scan_4x4_frame_avx   ( dctcoef level[16], dctcoef dct[16] );
+#define x264_zigzag_scan_4x4_frame_xop x264_template(zigzag_scan_4x4_frame_xop)
 void x264_zigzag_scan_4x4_frame_xop   ( dctcoef level[16], dctcoef dct[16] );
+#define x264_zigzag_scan_4x4_frame_avx512 x264_template(zigzag_scan_4x4_frame_avx512)
 void x264_zigzag_scan_4x4_frame_avx512( dctcoef level[16], dctcoef dct[16] );
+#define x264_zigzag_scan_4x4_field_sse x264_template(zigzag_scan_4x4_field_sse)
 void x264_zigzag_scan_4x4_field_sse   ( int16_t level[16], int16_t dct[16] );
+#define x264_zigzag_scan_4x4_field_sse2 x264_template(zigzag_scan_4x4_field_sse2)
 void x264_zigzag_scan_4x4_field_sse2  ( int32_t level[16], int32_t dct[16] );
+#define x264_zigzag_scan_4x4_field_avx512 x264_template(zigzag_scan_4x4_field_avx512)
 void x264_zigzag_scan_4x4_field_avx512( dctcoef level[16], dctcoef dct[16] );
+#define x264_zigzag_scan_8x8_field_mmx2 x264_template(zigzag_scan_8x8_field_mmx2)
 void x264_zigzag_scan_8x8_field_mmx2  ( int16_t level[64], int16_t dct[64] );
+#define x264_zigzag_scan_8x8_field_sse4 x264_template(zigzag_scan_8x8_field_sse4)
 void x264_zigzag_scan_8x8_field_sse4  ( int32_t level[64], int32_t dct[64] );
+#define x264_zigzag_scan_8x8_field_avx x264_template(zigzag_scan_8x8_field_avx)
 void x264_zigzag_scan_8x8_field_avx   ( int32_t level[64], int32_t dct[64] );
+#define x264_zigzag_scan_8x8_field_xop x264_template(zigzag_scan_8x8_field_xop)
 void x264_zigzag_scan_8x8_field_xop   ( int16_t level[64], int16_t dct[64] );
+#define x264_zigzag_scan_8x8_field_avx512 x264_template(zigzag_scan_8x8_field_avx512)
 void x264_zigzag_scan_8x8_field_avx512( dctcoef level[64], dctcoef dct[64] );
+#define x264_zigzag_sub_4x4_frame_avx x264_template(zigzag_sub_4x4_frame_avx)
 int  x264_zigzag_sub_4x4_frame_avx    ( int16_t level[16], const uint8_t *src, uint8_t *dst );
+#define x264_zigzag_sub_4x4_frame_ssse3 x264_template(zigzag_sub_4x4_frame_ssse3)
 int  x264_zigzag_sub_4x4_frame_ssse3  ( int16_t level[16], const uint8_t *src, uint8_t *dst );
+#define x264_zigzag_sub_4x4ac_frame_avx x264_template(zigzag_sub_4x4ac_frame_avx)
 int  x264_zigzag_sub_4x4ac_frame_avx  ( int16_t level[16], const uint8_t *src, uint8_t *dst, int16_t *dc );
+#define x264_zigzag_sub_4x4ac_frame_ssse3 x264_template(zigzag_sub_4x4ac_frame_ssse3)
 int  x264_zigzag_sub_4x4ac_frame_ssse3( int16_t level[16], const uint8_t *src, uint8_t *dst, int16_t *dc );
+#define x264_zigzag_sub_4x4_field_avx x264_template(zigzag_sub_4x4_field_avx)
 int  x264_zigzag_sub_4x4_field_avx    ( int16_t level[16], const uint8_t *src, uint8_t *dst );
+#define x264_zigzag_sub_4x4_field_ssse3 x264_template(zigzag_sub_4x4_field_ssse3)
 int  x264_zigzag_sub_4x4_field_ssse3  ( int16_t level[16], const uint8_t *src, uint8_t *dst );
+#define x264_zigzag_sub_4x4ac_field_avx x264_template(zigzag_sub_4x4ac_field_avx)
 int  x264_zigzag_sub_4x4ac_field_avx  ( int16_t level[16], const uint8_t *src, uint8_t *dst, int16_t *dc );
+#define x264_zigzag_sub_4x4ac_field_ssse3 x264_template(zigzag_sub_4x4ac_field_ssse3)
 int  x264_zigzag_sub_4x4ac_field_ssse3( int16_t level[16], const uint8_t *src, uint8_t *dst, int16_t *dc );
+#define x264_zigzag_interleave_8x8_cavlc_mmx x264_template(zigzag_interleave_8x8_cavlc_mmx)
 void x264_zigzag_interleave_8x8_cavlc_mmx   ( int16_t *dst, int16_t *src, uint8_t *nnz );
+#define x264_zigzag_interleave_8x8_cavlc_sse2 x264_template(zigzag_interleave_8x8_cavlc_sse2)
 void x264_zigzag_interleave_8x8_cavlc_sse2  ( dctcoef *dst, dctcoef *src, uint8_t *nnz );
+#define x264_zigzag_interleave_8x8_cavlc_avx x264_template(zigzag_interleave_8x8_cavlc_avx)
 void x264_zigzag_interleave_8x8_cavlc_avx   ( dctcoef *dst, dctcoef *src, uint8_t *nnz );
+#define x264_zigzag_interleave_8x8_cavlc_avx2 x264_template(zigzag_interleave_8x8_cavlc_avx2)
 void x264_zigzag_interleave_8x8_cavlc_avx2  ( int16_t *dst, int16_t *src, uint8_t *nnz );
+#define x264_zigzag_interleave_8x8_cavlc_avx512 x264_template(zigzag_interleave_8x8_cavlc_avx512)
 void x264_zigzag_interleave_8x8_cavlc_avx512( dctcoef *dst, dctcoef *src, uint8_t *nnz );
 
 #endif
diff --git a/common/x86/deblock.h b/common/x86/deblock.h
new file mode 100644 (file)
index 0000000..8a195d9
--- /dev/null
@@ -0,0 +1,146 @@
+/*****************************************************************************
+ * deblock.h: x86 deblocking
+ *****************************************************************************
+ * Copyright (C) 2017 x264 project
+ *
+ * Authors: Anton Mitrofanov <BugMaster@narod.ru>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@x264.com.
+ *****************************************************************************/
+
+#ifndef X264_X86_DEBLOCK_H
+#define X264_X86_DEBLOCK_H
+
+#define x264_deblock_v_luma_sse2 x264_template(deblock_v_luma_sse2)
+void x264_deblock_v_luma_sse2( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_v_luma_avx x264_template(deblock_v_luma_avx)
+void x264_deblock_v_luma_avx ( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_h_luma_sse2 x264_template(deblock_h_luma_sse2)
+void x264_deblock_h_luma_sse2( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_h_luma_avx x264_template(deblock_h_luma_avx)
+void x264_deblock_h_luma_avx ( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_v_chroma_sse2 x264_template(deblock_v_chroma_sse2)
+void x264_deblock_v_chroma_sse2( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_v_chroma_avx x264_template(deblock_v_chroma_avx)
+void x264_deblock_v_chroma_avx ( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_h_chroma_sse2 x264_template(deblock_h_chroma_sse2)
+void x264_deblock_h_chroma_sse2( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_h_chroma_avx x264_template(deblock_h_chroma_avx)
+void x264_deblock_h_chroma_avx ( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_h_chroma_mbaff_sse2 x264_template(deblock_h_chroma_mbaff_sse2)
+void x264_deblock_h_chroma_mbaff_sse2( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_h_chroma_mbaff_avx x264_template(deblock_h_chroma_mbaff_avx)
+void x264_deblock_h_chroma_mbaff_avx ( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_h_chroma_422_mmx2 x264_template(deblock_h_chroma_422_mmx2)
+void x264_deblock_h_chroma_422_mmx2( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_h_chroma_422_sse2 x264_template(deblock_h_chroma_422_sse2)
+void x264_deblock_h_chroma_422_sse2( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_h_chroma_422_avx x264_template(deblock_h_chroma_422_avx)
+void x264_deblock_h_chroma_422_avx ( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_v_luma_intra_sse2 x264_template(deblock_v_luma_intra_sse2)
+void x264_deblock_v_luma_intra_sse2( pixel *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_v_luma_intra_avx x264_template(deblock_v_luma_intra_avx)
+void x264_deblock_v_luma_intra_avx ( pixel *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_h_luma_intra_sse2 x264_template(deblock_h_luma_intra_sse2)
+void x264_deblock_h_luma_intra_sse2( pixel *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_h_luma_intra_avx x264_template(deblock_h_luma_intra_avx)
+void x264_deblock_h_luma_intra_avx ( pixel *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_v_chroma_intra_sse2 x264_template(deblock_v_chroma_intra_sse2)
+void x264_deblock_v_chroma_intra_sse2( pixel *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_v_chroma_intra_avx x264_template(deblock_v_chroma_intra_avx)
+void x264_deblock_v_chroma_intra_avx ( pixel *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_h_chroma_intra_sse2 x264_template(deblock_h_chroma_intra_sse2)
+void x264_deblock_h_chroma_intra_sse2( pixel *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_h_chroma_intra_avx x264_template(deblock_h_chroma_intra_avx)
+void x264_deblock_h_chroma_intra_avx ( pixel *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_h_chroma_422_intra_mmx2 x264_template(deblock_h_chroma_422_intra_mmx2)
+void x264_deblock_h_chroma_422_intra_mmx2( pixel *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_h_chroma_422_intra_sse2 x264_template(deblock_h_chroma_422_intra_sse2)
+void x264_deblock_h_chroma_422_intra_sse2( pixel *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_h_chroma_422_intra_avx x264_template(deblock_h_chroma_422_intra_avx)
+void x264_deblock_h_chroma_422_intra_avx ( pixel *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_strength_sse2 x264_template(deblock_strength_sse2)
+void x264_deblock_strength_sse2  ( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE],
+                                   int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][8][4],
+                                   int mvy_limit, int bframe );
+#define x264_deblock_strength_ssse3 x264_template(deblock_strength_ssse3)
+void x264_deblock_strength_ssse3 ( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE],
+                                   int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][8][4],
+                                   int mvy_limit, int bframe );
+#define x264_deblock_strength_avx x264_template(deblock_strength_avx)
+void x264_deblock_strength_avx   ( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE],
+                                   int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][8][4],
+                                   int mvy_limit, int bframe );
+#define x264_deblock_strength_avx2 x264_template(deblock_strength_avx2)
+void x264_deblock_strength_avx2  ( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE],
+                                   int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][8][4],
+                                   int mvy_limit, int bframe );
+#define x264_deblock_strength_avx512 x264_template(deblock_strength_avx512)
+void x264_deblock_strength_avx512( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE],
+                                   int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][8][4],
+                                   int mvy_limit, int bframe );
+
+#define x264_deblock_h_chroma_intra_mbaff_mmx2 x264_template(deblock_h_chroma_intra_mbaff_mmx2)
+void x264_deblock_h_chroma_intra_mbaff_mmx2( pixel *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_h_chroma_intra_mbaff_sse2 x264_template(deblock_h_chroma_intra_mbaff_sse2)
+void x264_deblock_h_chroma_intra_mbaff_sse2( pixel *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_h_chroma_intra_mbaff_avx x264_template(deblock_h_chroma_intra_mbaff_avx)
+void x264_deblock_h_chroma_intra_mbaff_avx ( pixel *pix, intptr_t stride, int alpha, int beta );
+#if ARCH_X86
+#define x264_deblock_h_luma_mmx2 x264_template(deblock_h_luma_mmx2)
+void x264_deblock_h_luma_mmx2( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_v8_luma_mmx2 x264_template(deblock_v8_luma_mmx2)
+void x264_deblock_v8_luma_mmx2( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_v_chroma_mmx2 x264_template(deblock_v_chroma_mmx2)
+void x264_deblock_v_chroma_mmx2( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_h_chroma_mmx2 x264_template(deblock_h_chroma_mmx2)
+void x264_deblock_h_chroma_mmx2( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_h_chroma_mbaff_mmx2 x264_template(deblock_h_chroma_mbaff_mmx2)
+void x264_deblock_h_chroma_mbaff_mmx2( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+#define x264_deblock_h_luma_intra_mmx2 x264_template(deblock_h_luma_intra_mmx2)
+void x264_deblock_h_luma_intra_mmx2( pixel *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_v8_luma_intra_mmx2 x264_template(deblock_v8_luma_intra_mmx2)
+void x264_deblock_v8_luma_intra_mmx2( uint8_t *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_v_chroma_intra_mmx2 x264_template(deblock_v_chroma_intra_mmx2)
+void x264_deblock_v_chroma_intra_mmx2( pixel *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_h_chroma_intra_mmx2 x264_template(deblock_h_chroma_intra_mmx2)
+void x264_deblock_h_chroma_intra_mmx2( pixel *pix, intptr_t stride, int alpha, int beta );
+#define x264_deblock_v_chroma_intra_mbaff_mmx2 x264_template(deblock_v_chroma_intra_mbaff_mmx2)
+void x264_deblock_h_chroma_intra_mbaff_mmx2( pixel *pix, intptr_t stride, int alpha, int beta );
+
+#define x264_deblock_v_luma_mmx2 x264_template(deblock_v_luma_mmx2)
+#define x264_deblock_v_luma_intra_mmx2 x264_template(deblock_v_luma_intra_mmx2)
+#if HIGH_BIT_DEPTH
+void x264_deblock_v_luma_mmx2( pixel *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
+void x264_deblock_v_luma_intra_mmx2( pixel *pix, intptr_t stride, int alpha, int beta );
+#else
+// FIXME this wrapper has a significant cpu cost
+static ALWAYS_INLINE void x264_deblock_v_luma_mmx2( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 )
+{
+    x264_deblock_v8_luma_mmx2( pix,   stride, alpha, beta, tc0   );
+    x264_deblock_v8_luma_mmx2( pix+8, stride, alpha, beta, tc0+2 );
+}
+static ALWAYS_INLINE void x264_deblock_v_luma_intra_mmx2( uint8_t *pix, intptr_t stride, int alpha, int beta )
+{
+    x264_deblock_v8_luma_intra_mmx2( pix,   stride, alpha, beta );
+    x264_deblock_v8_luma_intra_mmx2( pix+8, stride, alpha, beta );
+}
+#endif // HIGH_BIT_DEPTH
+#endif
+
+#endif
index e617c2e0b6b140d7d7ce2b6dd78654601e6ab9fa..e020fd509ea7f65ca39713c4cbb921780c228d14 100644 (file)
 #include "common/common.h"
 #include "mc.h"
 
+#define x264_pixel_avg_16x16_avx2 x264_template(pixel_avg_16x16_avx2)
+#define x264_pixel_avg_16x16_avx512 x264_template(pixel_avg_16x16_avx512)
+#define x264_pixel_avg_16x16_mmx2 x264_template(pixel_avg_16x16_mmx2)
+#define x264_pixel_avg_16x16_sse2 x264_template(pixel_avg_16x16_sse2)
+#define x264_pixel_avg_16x16_ssse3 x264_template(pixel_avg_16x16_ssse3)
+#define x264_pixel_avg_16x8_avx2 x264_template(pixel_avg_16x8_avx2)
+#define x264_pixel_avg_16x8_avx512 x264_template(pixel_avg_16x8_avx512)
+#define x264_pixel_avg_16x8_mmx2 x264_template(pixel_avg_16x8_mmx2)
+#define x264_pixel_avg_16x8_sse2 x264_template(pixel_avg_16x8_sse2)
+#define x264_pixel_avg_16x8_ssse3 x264_template(pixel_avg_16x8_ssse3)
+#define x264_pixel_avg_4x16_mmx2 x264_template(pixel_avg_4x16_mmx2)
+#define x264_pixel_avg_4x16_sse2 x264_template(pixel_avg_4x16_sse2)
+#define x264_pixel_avg_4x16_ssse3 x264_template(pixel_avg_4x16_ssse3)
+#define x264_pixel_avg_4x2_mmx2 x264_template(pixel_avg_4x2_mmx2)
+#define x264_pixel_avg_4x2_sse2 x264_template(pixel_avg_4x2_sse2)
+#define x264_pixel_avg_4x2_ssse3 x264_template(pixel_avg_4x2_ssse3)
+#define x264_pixel_avg_4x4_mmx2 x264_template(pixel_avg_4x4_mmx2)
+#define x264_pixel_avg_4x4_sse2 x264_template(pixel_avg_4x4_sse2)
+#define x264_pixel_avg_4x4_ssse3 x264_template(pixel_avg_4x4_ssse3)
+#define x264_pixel_avg_4x8_mmx2 x264_template(pixel_avg_4x8_mmx2)
+#define x264_pixel_avg_4x8_sse2 x264_template(pixel_avg_4x8_sse2)
+#define x264_pixel_avg_4x8_ssse3 x264_template(pixel_avg_4x8_ssse3)
+#define x264_pixel_avg_8x16_avx512 x264_template(pixel_avg_8x16_avx512)
+#define x264_pixel_avg_8x16_mmx2 x264_template(pixel_avg_8x16_mmx2)
+#define x264_pixel_avg_8x16_sse2 x264_template(pixel_avg_8x16_sse2)
+#define x264_pixel_avg_8x16_ssse3 x264_template(pixel_avg_8x16_ssse3)
+#define x264_pixel_avg_8x4_avx512 x264_template(pixel_avg_8x4_avx512)
+#define x264_pixel_avg_8x4_mmx2 x264_template(pixel_avg_8x4_mmx2)
+#define x264_pixel_avg_8x4_sse2 x264_template(pixel_avg_8x4_sse2)
+#define x264_pixel_avg_8x4_ssse3 x264_template(pixel_avg_8x4_ssse3)
+#define x264_pixel_avg_8x8_avx512 x264_template(pixel_avg_8x8_avx512)
+#define x264_pixel_avg_8x8_mmx2 x264_template(pixel_avg_8x8_mmx2)
+#define x264_pixel_avg_8x8_sse2 x264_template(pixel_avg_8x8_sse2)
+#define x264_pixel_avg_8x8_ssse3 x264_template(pixel_avg_8x8_ssse3)
 #define DECL_SUF( func, args )\
     void func##_mmx2 args;\
     void func##_sse2 args;\
@@ -45,9 +79,41 @@ DECL_SUF( x264_pixel_avg_4x8,   ( pixel *, intptr_t, pixel *, intptr_t, pixel *,
 DECL_SUF( x264_pixel_avg_4x4,   ( pixel *, intptr_t, pixel *, intptr_t, pixel *, intptr_t, int ))
 DECL_SUF( x264_pixel_avg_4x2,   ( pixel *, intptr_t, pixel *, intptr_t, pixel *, intptr_t, int ))
 
+#define x264_mc_weight_w12_mmx2 x264_template(mc_weight_w12_mmx2)
+#define x264_mc_weight_w12_sse2 x264_template(mc_weight_w12_sse2)
+#define x264_mc_weight_w16_avx2 x264_template(mc_weight_w16_avx2)
+#define x264_mc_weight_w16_mmx2 x264_template(mc_weight_w16_mmx2)
+#define x264_mc_weight_w16_sse2 x264_template(mc_weight_w16_sse2)
+#define x264_mc_weight_w16_ssse3 x264_template(mc_weight_w16_ssse3)
+#define x264_mc_weight_w20_avx2 x264_template(mc_weight_w20_avx2)
+#define x264_mc_weight_w20_mmx2 x264_template(mc_weight_w20_mmx2)
+#define x264_mc_weight_w20_sse2 x264_template(mc_weight_w20_sse2)
+#define x264_mc_weight_w20_ssse3 x264_template(mc_weight_w20_ssse3)
+#define x264_mc_weight_w4_mmx2 x264_template(mc_weight_w4_mmx2)
+#define x264_mc_weight_w4_ssse3 x264_template(mc_weight_w4_ssse3)
+#define x264_mc_weight_w8_avx2 x264_template(mc_weight_w8_avx2)
+#define x264_mc_weight_w8_mmx2 x264_template(mc_weight_w8_mmx2)
+#define x264_mc_weight_w8_sse2 x264_template(mc_weight_w8_sse2)
+#define x264_mc_weight_w8_ssse3 x264_template(mc_weight_w8_ssse3)
 #define MC_WEIGHT(w,type) \
     void x264_mc_weight_w##w##_##type( pixel *, intptr_t, pixel *, intptr_t, const x264_weight_t *, int );
 
+#define x264_mc_offsetadd_w12_mmx2 x264_template(mc_offsetadd_w12_mmx2)
+#define x264_mc_offsetadd_w16_mmx2 x264_template(mc_offsetadd_w16_mmx2)
+#define x264_mc_offsetadd_w16_sse2 x264_template(mc_offsetadd_w16_sse2)
+#define x264_mc_offsetadd_w20_mmx2 x264_template(mc_offsetadd_w20_mmx2)
+#define x264_mc_offsetadd_w20_sse2 x264_template(mc_offsetadd_w20_sse2)
+#define x264_mc_offsetadd_w4_mmx2 x264_template(mc_offsetadd_w4_mmx2)
+#define x264_mc_offsetadd_w8_mmx2 x264_template(mc_offsetadd_w8_mmx2)
+#define x264_mc_offsetadd_w8_sse2 x264_template(mc_offsetadd_w8_sse2)
+#define x264_mc_offsetsub_w12_mmx2 x264_template(mc_offsetsub_w12_mmx2)
+#define x264_mc_offsetsub_w16_mmx2 x264_template(mc_offsetsub_w16_mmx2)
+#define x264_mc_offsetsub_w16_sse2 x264_template(mc_offsetsub_w16_sse2)
+#define x264_mc_offsetsub_w20_mmx2 x264_template(mc_offsetsub_w20_mmx2)
+#define x264_mc_offsetsub_w20_sse2 x264_template(mc_offsetsub_w20_sse2)
+#define x264_mc_offsetsub_w4_mmx2 x264_template(mc_offsetsub_w4_mmx2)
+#define x264_mc_offsetsub_w8_mmx2 x264_template(mc_offsetsub_w8_mmx2)
+#define x264_mc_offsetsub_w8_sse2 x264_template(mc_offsetsub_w8_sse2)
 #define MC_WEIGHT_OFFSET(w,type) \
     void x264_mc_offsetadd_w##w##_##type( pixel *, intptr_t, pixel *, intptr_t, const x264_weight_t *, int ); \
     void x264_mc_offsetsub_w##w##_##type( pixel *, intptr_t, pixel *, intptr_t, const x264_weight_t *, int ); \
@@ -76,110 +142,183 @@ MC_WEIGHT( 20, avx2 )
 #undef MC_OFFSET
 #undef MC_WEIGHT
 
+#define x264_mc_copy_w4_mmx x264_template(mc_copy_w4_mmx)
 void x264_mc_copy_w4_mmx ( pixel *, intptr_t, pixel *, intptr_t, int );
+#define x264_mc_copy_w8_mmx x264_template(mc_copy_w8_mmx)
 void x264_mc_copy_w8_mmx ( pixel *, intptr_t, pixel *, intptr_t, int );
+#define x264_mc_copy_w8_sse x264_template(mc_copy_w8_sse)
 void x264_mc_copy_w8_sse ( pixel *, intptr_t, pixel *, intptr_t, int );
+#define x264_mc_copy_w16_mmx x264_template(mc_copy_w16_mmx)
 void x264_mc_copy_w16_mmx( pixel *, intptr_t, pixel *, intptr_t, int );
+#define x264_mc_copy_w16_sse x264_template(mc_copy_w16_sse)
 void x264_mc_copy_w16_sse( pixel *, intptr_t, pixel *, intptr_t, int );
+#define x264_mc_copy_w16_aligned_sse x264_template(mc_copy_w16_aligned_sse)
 void x264_mc_copy_w16_aligned_sse( pixel *, intptr_t, pixel *, intptr_t, int );
+#define x264_mc_copy_w16_avx x264_template(mc_copy_w16_avx)
 void x264_mc_copy_w16_avx( uint16_t *, intptr_t, uint16_t *, intptr_t, int );
+#define x264_mc_copy_w16_aligned_avx x264_template(mc_copy_w16_aligned_avx)
 void x264_mc_copy_w16_aligned_avx( uint16_t *, intptr_t, uint16_t *, intptr_t, int );
+#define x264_prefetch_fenc_420_mmx2 x264_template(prefetch_fenc_420_mmx2)
 void x264_prefetch_fenc_420_mmx2( pixel *, intptr_t, pixel *, intptr_t, int );
+#define x264_prefetch_fenc_422_mmx2 x264_template(prefetch_fenc_422_mmx2)
 void x264_prefetch_fenc_422_mmx2( pixel *, intptr_t, pixel *, intptr_t, int );
+#define x264_prefetch_ref_mmx2 x264_template(prefetch_ref_mmx2)
 void x264_prefetch_ref_mmx2( pixel *, intptr_t, int );
+#define x264_plane_copy_core_sse x264_template(plane_copy_core_sse)
 void x264_plane_copy_core_sse( pixel *, intptr_t, pixel *, intptr_t, int w, int h );
+#define x264_plane_copy_core_avx x264_template(plane_copy_core_avx)
 void x264_plane_copy_core_avx( pixel *, intptr_t, pixel *, intptr_t, int w, int h );
+#define x264_plane_copy_swap_core_ssse3 x264_template(plane_copy_swap_core_ssse3)
 void x264_plane_copy_swap_core_ssse3( pixel *, intptr_t, pixel *, intptr_t, int w, int h );
+#define x264_plane_copy_swap_core_avx2 x264_template(plane_copy_swap_core_avx2)
 void x264_plane_copy_swap_core_avx2 ( pixel *, intptr_t, pixel *, intptr_t, int w, int h );
+#define x264_plane_copy_interleave_core_mmx2 x264_template(plane_copy_interleave_core_mmx2)
 void x264_plane_copy_interleave_core_mmx2( pixel *dst,  intptr_t i_dst,
                                            pixel *srcu, intptr_t i_srcu,
                                            pixel *srcv, intptr_t i_srcv, int w, int h );
+#define x264_plane_copy_interleave_core_sse2 x264_template(plane_copy_interleave_core_sse2)
 void x264_plane_copy_interleave_core_sse2( pixel *dst,  intptr_t i_dst,
                                            pixel *srcu, intptr_t i_srcu,
                                            pixel *srcv, intptr_t i_srcv, int w, int h );
+#define x264_plane_copy_interleave_core_avx x264_template(plane_copy_interleave_core_avx)
 void x264_plane_copy_interleave_core_avx( pixel *dst,  intptr_t i_dst,
                                           pixel *srcu, intptr_t i_srcu,
                                           pixel *srcv, intptr_t i_srcv, int w, int h );
+#define x264_plane_copy_deinterleave_sse2 x264_template(plane_copy_deinterleave_sse2)
 void x264_plane_copy_deinterleave_sse2( pixel *dsta, intptr_t i_dsta,
                                         pixel *dstb, intptr_t i_dstb,
                                         pixel *src,  intptr_t i_src, int w, int h );
+#define x264_plane_copy_deinterleave_ssse3 x264_template(plane_copy_deinterleave_ssse3)
 void x264_plane_copy_deinterleave_ssse3( uint8_t *dsta, intptr_t i_dsta,
                                          uint8_t *dstb, intptr_t i_dstb,
                                          uint8_t *src,  intptr_t i_src, int w, int h );
+#define x264_plane_copy_deinterleave_avx x264_template(plane_copy_deinterleave_avx)
 void x264_plane_copy_deinterleave_avx( uint16_t *dsta, intptr_t i_dsta,
                                        uint16_t *dstb, intptr_t i_dstb,
                                        uint16_t *src,  intptr_t i_src, int w, int h );
+#define x264_plane_copy_deinterleave_avx2 x264_template(plane_copy_deinterleave_avx2)
 void x264_plane_copy_deinterleave_avx2( pixel *dsta, intptr_t i_dsta,
                                         pixel *dstb, intptr_t i_dstb,
                                         pixel *src,  intptr_t i_src, int w, int h );
+#define x264_plane_copy_deinterleave_rgb_sse2 x264_template(plane_copy_deinterleave_rgb_sse2)
 void x264_plane_copy_deinterleave_rgb_sse2 ( pixel *dsta, intptr_t i_dsta,
                                              pixel *dstb, intptr_t i_dstb,
                                              pixel *dstc, intptr_t i_dstc,
                                              pixel *src,  intptr_t i_src, int pw, int w, int h );
+#define x264_plane_copy_deinterleave_rgb_ssse3 x264_template(plane_copy_deinterleave_rgb_ssse3)
 void x264_plane_copy_deinterleave_rgb_ssse3( pixel *dsta, intptr_t i_dsta,
                                              pixel *dstb, intptr_t i_dstb,
                                              pixel *dstc, intptr_t i_dstc,
                                              pixel *src,  intptr_t i_src, int pw, int w, int h );
+#define x264_plane_copy_deinterleave_rgb_avx2 x264_template(plane_copy_deinterleave_rgb_avx2)
 void x264_plane_copy_deinterleave_rgb_avx2 ( pixel *dsta, intptr_t i_dsta,
                                              pixel *dstb, intptr_t i_dstb,
                                              pixel *dstc, intptr_t i_dstc,
                                              pixel *src,  intptr_t i_src, int pw, int w, int h );
+#define x264_plane_copy_deinterleave_v210_ssse3 x264_template(plane_copy_deinterleave_v210_ssse3)
 void x264_plane_copy_deinterleave_v210_ssse3 ( uint16_t *dstu, intptr_t i_dstu,
                                                uint16_t *dstv, intptr_t i_dstv,
                                                uint32_t *src,  intptr_t i_src, int w, int h );
+#define x264_plane_copy_deinterleave_v210_avx x264_template(plane_copy_deinterleave_v210_avx)
 void x264_plane_copy_deinterleave_v210_avx   ( uint16_t *dstu, intptr_t i_dstu,
                                                uint16_t *dstv, intptr_t i_dstv,
                                                uint32_t *src,  intptr_t i_src, int w, int h );
+#define x264_plane_copy_deinterleave_v210_avx2 x264_template(plane_copy_deinterleave_v210_avx2)
 void x264_plane_copy_deinterleave_v210_avx2  ( uint16_t *dstu, intptr_t i_dstu,
                                                uint16_t *dstv, intptr_t i_dstv,
                                                uint32_t *src,  intptr_t i_src, int w, int h );
+#define x264_plane_copy_deinterleave_v210_avx512 x264_template(plane_copy_deinterleave_v210_avx512)
 void x264_plane_copy_deinterleave_v210_avx512( uint16_t *dstu, intptr_t i_dstu,
                                                uint16_t *dstv, intptr_t i_dstv,
                                                uint32_t *src,  intptr_t i_src, int w, int h );
+#define x264_store_interleave_chroma_mmx2 x264_template(store_interleave_chroma_mmx2)
 void x264_store_interleave_chroma_mmx2( pixel *dst, intptr_t i_dst, pixel *srcu, pixel *srcv, int height );
+#define x264_store_interleave_chroma_sse2 x264_template(store_interleave_chroma_sse2)
 void x264_store_interleave_chroma_sse2( pixel *dst, intptr_t i_dst, pixel *srcu, pixel *srcv, int height );
+#define x264_store_interleave_chroma_avx x264_template(store_interleave_chroma_avx)
 void x264_store_interleave_chroma_avx ( pixel *dst, intptr_t i_dst, pixel *srcu, pixel *srcv, int height );
+#define x264_load_deinterleave_chroma_fenc_sse2 x264_template(load_deinterleave_chroma_fenc_sse2)
 void x264_load_deinterleave_chroma_fenc_sse2( pixel *dst, pixel *src, intptr_t i_src, int height );
+#define x264_load_deinterleave_chroma_fenc_ssse3 x264_template(load_deinterleave_chroma_fenc_ssse3)
 void x264_load_deinterleave_chroma_fenc_ssse3( uint8_t *dst, uint8_t *src, intptr_t i_src, int height );
+#define x264_load_deinterleave_chroma_fenc_avx x264_template(load_deinterleave_chroma_fenc_avx)
 void x264_load_deinterleave_chroma_fenc_avx( uint16_t *dst, uint16_t *src, intptr_t i_src, int height );
+#define x264_load_deinterleave_chroma_fenc_avx2 x264_template(load_deinterleave_chroma_fenc_avx2)
 void x264_load_deinterleave_chroma_fenc_avx2( pixel *dst, pixel *src, intptr_t i_src, int height );
+#define x264_load_deinterleave_chroma_fdec_sse2 x264_template(load_deinterleave_chroma_fdec_sse2)
 void x264_load_deinterleave_chroma_fdec_sse2( pixel *dst, pixel *src, intptr_t i_src, int height );
+#define x264_load_deinterleave_chroma_fdec_ssse3 x264_template(load_deinterleave_chroma_fdec_ssse3)
 void x264_load_deinterleave_chroma_fdec_ssse3( uint8_t *dst, uint8_t *src, intptr_t i_src, int height );
+#define x264_load_deinterleave_chroma_fdec_avx x264_template(load_deinterleave_chroma_fdec_avx)
 void x264_load_deinterleave_chroma_fdec_avx( uint16_t *dst, uint16_t *src, intptr_t i_src, int height );
+#define x264_load_deinterleave_chroma_fdec_avx2 x264_template(load_deinterleave_chroma_fdec_avx2)
 void x264_load_deinterleave_chroma_fdec_avx2( uint16_t *dst, uint16_t *src, intptr_t i_src, int height );
+#define x264_memcpy_aligned_sse x264_template(memcpy_aligned_sse)
 void *x264_memcpy_aligned_sse   ( void *dst, const void *src, size_t n );
+#define x264_memcpy_aligned_avx x264_template(memcpy_aligned_avx)
 void *x264_memcpy_aligned_avx   ( void *dst, const void *src, size_t n );
+#define x264_memcpy_aligned_avx512 x264_template(memcpy_aligned_avx512)
 void *x264_memcpy_aligned_avx512( void *dst, const void *src, size_t n );
+#define x264_memzero_aligned_sse x264_template(memzero_aligned_sse)
 void x264_memzero_aligned_sse   ( void *dst, size_t n );
+#define x264_memzero_aligned_avx x264_template(memzero_aligned_avx)
 void x264_memzero_aligned_avx   ( void *dst, size_t n );
+#define x264_memzero_aligned_avx512 x264_template(memzero_aligned_avx512)
 void x264_memzero_aligned_avx512( void *dst, size_t n );
+#define x264_integral_init4h_sse4 x264_template(integral_init4h_sse4)
 void x264_integral_init4h_sse4( uint16_t *sum, uint8_t *pix, intptr_t stride );
+#define x264_integral_init4h_avx2 x264_template(integral_init4h_avx2)
 void x264_integral_init4h_avx2( uint16_t *sum, uint8_t *pix, intptr_t stride );
+#define x264_integral_init8h_sse4 x264_template(integral_init8h_sse4)
 void x264_integral_init8h_sse4( uint16_t *sum, uint8_t *pix, intptr_t stride );
+#define x264_integral_init8h_avx x264_template(integral_init8h_avx)
 void x264_integral_init8h_avx ( uint16_t *sum, uint8_t *pix, intptr_t stride );
+#define x264_integral_init8h_avx2 x264_template(integral_init8h_avx2)
 void x264_integral_init8h_avx2( uint16_t *sum, uint8_t *pix, intptr_t stride );
+#define x264_integral_init4v_mmx x264_template(integral_init4v_mmx)
 void x264_integral_init4v_mmx  ( uint16_t *sum8, uint16_t *sum4, intptr_t stride );
+#define x264_integral_init4v_sse2 x264_template(integral_init4v_sse2)
 void x264_integral_init4v_sse2 ( uint16_t *sum8, uint16_t *sum4, intptr_t stride );
+#define x264_integral_init4v_ssse3 x264_template(integral_init4v_ssse3)
 void x264_integral_init4v_ssse3( uint16_t *sum8, uint16_t *sum4, intptr_t stride );
+#define x264_integral_init4v_avx2 x264_template(integral_init4v_avx2)
 void x264_integral_init4v_avx2( uint16_t *sum8, uint16_t *sum4, intptr_t stride );
+#define x264_integral_init8v_mmx x264_template(integral_init8v_mmx)
 void x264_integral_init8v_mmx ( uint16_t *sum8, intptr_t stride );
+#define x264_integral_init8v_sse2 x264_template(integral_init8v_sse2)
 void x264_integral_init8v_sse2( uint16_t *sum8, intptr_t stride );
+#define x264_integral_init8v_avx2 x264_template(integral_init8v_avx2)
 void x264_integral_init8v_avx2( uint16_t *sum8, intptr_t stride );
+#define x264_mbtree_propagate_cost_sse2 x264_template(mbtree_propagate_cost_sse2)
 void x264_mbtree_propagate_cost_sse2  ( int16_t *dst, uint16_t *propagate_in, uint16_t *intra_costs,
                                         uint16_t *inter_costs, uint16_t *inv_qscales, float *fps_factor, int len );
+#define x264_mbtree_propagate_cost_avx x264_template(mbtree_propagate_cost_avx)
 void x264_mbtree_propagate_cost_avx   ( int16_t *dst, uint16_t *propagate_in, uint16_t *intra_costs,
                                         uint16_t *inter_costs, uint16_t *inv_qscales, float *fps_factor, int len );
+#define x264_mbtree_propagate_cost_fma4 x264_template(mbtree_propagate_cost_fma4)
 void x264_mbtree_propagate_cost_fma4  ( int16_t *dst, uint16_t *propagate_in, uint16_t *intra_costs,
                                         uint16_t *inter_costs, uint16_t *inv_qscales, float *fps_factor, int len );
+#define x264_mbtree_propagate_cost_avx2 x264_template(mbtree_propagate_cost_avx2)
 void x264_mbtree_propagate_cost_avx2  ( int16_t *dst, uint16_t *propagate_in, uint16_t *intra_costs,
                                         uint16_t *inter_costs, uint16_t *inv_qscales, float *fps_factor, int len );
+#define x264_mbtree_propagate_cost_avx512 x264_template(mbtree_propagate_cost_avx512)
 void x264_mbtree_propagate_cost_avx512( int16_t *dst, uint16_t *propagate_in, uint16_t *intra_costs,
                                         uint16_t *inter_costs, uint16_t *inv_qscales, float *fps_factor, int len );
+#define x264_mbtree_fix8_pack_ssse3 x264_template(mbtree_fix8_pack_ssse3)
 void x264_mbtree_fix8_pack_ssse3( uint16_t *dst, float *src, int count );
+#define x264_mbtree_fix8_pack_avx2 x264_template(mbtree_fix8_pack_avx2)
 void x264_mbtree_fix8_pack_avx2 ( uint16_t *dst, float *src, int count );
+#define x264_mbtree_fix8_unpack_ssse3 x264_template(mbtree_fix8_unpack_ssse3)
 void x264_mbtree_fix8_unpack_ssse3( float *dst, uint16_t *src, int count );
+#define x264_mbtree_fix8_unpack_avx2 x264_template(mbtree_fix8_unpack_avx2)
 void x264_mbtree_fix8_unpack_avx2 ( float *dst, uint16_t *src, int count );
 
+#define x264_mc_chroma_avx x264_template(mc_chroma_avx)
+#define x264_mc_chroma_avx2 x264_template(mc_chroma_avx2)
+#define x264_mc_chroma_cache64_ssse3 x264_template(mc_chroma_cache64_ssse3)
+#define x264_mc_chroma_mmx2 x264_template(mc_chroma_mmx2)
+#define x264_mc_chroma_sse2 x264_template(mc_chroma_sse2)
+#define x264_mc_chroma_ssse3 x264_template(mc_chroma_ssse3)
 #define MC_CHROMA(cpu)\
 void x264_mc_chroma_##cpu( pixel *dstu, pixel *dstv, intptr_t i_dst, pixel *src, intptr_t i_src,\
                            int dx, int dy, int i_width, int i_height );
@@ -190,6 +329,13 @@ MC_CHROMA(cache64_ssse3)
 MC_CHROMA(avx)
 MC_CHROMA(avx2)
 
+#define x264_frame_init_lowres_core_avx x264_template(frame_init_lowres_core_avx)
+#define x264_frame_init_lowres_core_avx2 x264_template(frame_init_lowres_core_avx2)
+#define x264_frame_init_lowres_core_mmx2 x264_template(frame_init_lowres_core_mmx2)
+#define x264_frame_init_lowres_core_cache32_mmx2 x264_template(frame_init_lowres_core_cache32_mmx2)
+#define x264_frame_init_lowres_core_sse2 x264_template(frame_init_lowres_core_sse2)
+#define x264_frame_init_lowres_core_ssse3 x264_template(frame_init_lowres_core_ssse3)
+#define x264_frame_init_lowres_core_xop x264_template(frame_init_lowres_core_xop)
 #define LOWRES(cpu)\
 void x264_frame_init_lowres_core_##cpu( pixel *src0, pixel *dst0, pixel *dsth, pixel *dstv, pixel *dstc,\
                                         intptr_t src_stride, intptr_t dst_stride, int width, int height );
@@ -201,6 +347,32 @@ LOWRES(avx)
 LOWRES(xop)
 LOWRES(avx2)
 
+#define x264_pixel_avg2_w10_mmx2 x264_template(pixel_avg2_w10_mmx2)
+#define x264_pixel_avg2_w10_sse2 x264_template(pixel_avg2_w10_sse2)
+#define x264_pixel_avg2_w12_cache32_mmx2 x264_template(pixel_avg2_w12_cache32_mmx2)
+#define x264_pixel_avg2_w12_cache64_mmx2 x264_template(pixel_avg2_w12_cache64_mmx2)
+#define x264_pixel_avg2_w12_mmx2 x264_template(pixel_avg2_w12_mmx2)
+#define x264_pixel_avg2_w16_avx2 x264_template(pixel_avg2_w16_avx2)
+#define x264_pixel_avg2_w16_cache32_mmx2 x264_template(pixel_avg2_w16_cache32_mmx2)
+#define x264_pixel_avg2_w16_cache64_mmx2 x264_template(pixel_avg2_w16_cache64_mmx2)
+#define x264_pixel_avg2_w16_cache64_sse2 x264_template(pixel_avg2_w16_cache64_sse2)
+#define x264_pixel_avg2_w16_cache64_ssse3 x264_template(pixel_avg2_w16_cache64_ssse3)
+#define x264_pixel_avg2_w16_mmx2 x264_template(pixel_avg2_w16_mmx2)
+#define x264_pixel_avg2_w16_sse2 x264_template(pixel_avg2_w16_sse2)
+#define x264_pixel_avg2_w18_avx2 x264_template(pixel_avg2_w18_avx2)
+#define x264_pixel_avg2_w18_mmx2 x264_template(pixel_avg2_w18_mmx2)
+#define x264_pixel_avg2_w18_sse2 x264_template(pixel_avg2_w18_sse2)
+#define x264_pixel_avg2_w20_avx2 x264_template(pixel_avg2_w20_avx2)
+#define x264_pixel_avg2_w20_cache32_mmx2 x264_template(pixel_avg2_w20_cache32_mmx2)
+#define x264_pixel_avg2_w20_cache64_mmx2 x264_template(pixel_avg2_w20_cache64_mmx2)
+#define x264_pixel_avg2_w20_cache64_sse2 x264_template(pixel_avg2_w20_cache64_sse2)
+#define x264_pixel_avg2_w20_mmx2 x264_template(pixel_avg2_w20_mmx2)
+#define x264_pixel_avg2_w20_sse2 x264_template(pixel_avg2_w20_sse2)
+#define x264_pixel_avg2_w4_mmx2 x264_template(pixel_avg2_w4_mmx2)
+#define x264_pixel_avg2_w8_cache32_mmx2 x264_template(pixel_avg2_w8_cache32_mmx2)
+#define x264_pixel_avg2_w8_cache64_mmx2 x264_template(pixel_avg2_w8_cache64_mmx2)
+#define x264_pixel_avg2_w8_mmx2 x264_template(pixel_avg2_w8_mmx2)
+#define x264_pixel_avg2_w8_sse2 x264_template(pixel_avg2_w8_sse2)
 #define PIXEL_AVG_W(width,cpu)\
 void x264_pixel_avg2_w##width##_##cpu( pixel *, intptr_t, pixel *, intptr_t, pixel *, intptr_t );
 /* This declares some functions that don't exist, but that isn't a problem. */
@@ -228,6 +400,10 @@ static void (* const pixel_avg_wtab_##instr[6])( pixel *, intptr_t, pixel *, int
 
 #if HIGH_BIT_DEPTH
 /* we can replace w12/w20 with w10/w18 as only 9/17 pixels in fact are important */
+#undef x264_pixel_avg2_w12_mmx2
+#undef x264_pixel_avg2_w20_mmx2
+#undef x264_pixel_avg2_w20_sse2
+#undef x264_pixel_avg2_w20_avx2
 #define x264_pixel_avg2_w12_mmx2       x264_pixel_avg2_w10_mmx2
 #define x264_pixel_avg2_w20_mmx2       x264_pixel_avg2_w18_mmx2
 #define x264_pixel_avg2_w12_sse2         x264_pixel_avg2_w10_sse2
@@ -455,6 +631,25 @@ GET_REF(cache64_ssse3)
 GET_REF(cache64_ssse3_atom)
 #endif // !HIGH_BIT_DEPTH
 
+#define x264_hpel_filter_avx x264_template(hpel_filter_avx)
+#define x264_hpel_filter_avx2 x264_template(hpel_filter_avx2)
+#define x264_hpel_filter_c_mmx2 x264_template(hpel_filter_c_mmx2)
+#define x264_hpel_filter_c_sse2 x264_template(hpel_filter_c_sse2)
+#define x264_hpel_filter_c_ssse3 x264_template(hpel_filter_c_ssse3)
+#define x264_hpel_filter_c_avx x264_template(hpel_filter_c_avx)
+#define x264_hpel_filter_c_avx2 x264_template(hpel_filter_c_avx2)
+#define x264_hpel_filter_h_mmx2 x264_template(hpel_filter_h_mmx2)
+#define x264_hpel_filter_h_sse2 x264_template(hpel_filter_h_sse2)
+#define x264_hpel_filter_h_ssse3 x264_template(hpel_filter_h_ssse3)
+#define x264_hpel_filter_h_avx x264_template(hpel_filter_h_avx)
+#define x264_hpel_filter_h_avx2 x264_template(hpel_filter_h_avx2)
+#define x264_hpel_filter_sse2 x264_template(hpel_filter_sse2)
+#define x264_hpel_filter_ssse3 x264_template(hpel_filter_ssse3)
+#define x264_hpel_filter_v_mmx2 x264_template(hpel_filter_v_mmx2)
+#define x264_hpel_filter_v_sse2 x264_template(hpel_filter_v_sse2)
+#define x264_hpel_filter_v_ssse3 x264_template(hpel_filter_v_ssse3)
+#define x264_hpel_filter_v_avx x264_template(hpel_filter_v_avx)
+#define x264_hpel_filter_v_avx2 x264_template(hpel_filter_v_avx2)
 #define HPEL(align, cpu, cpuv, cpuc, cpuh)\
 void x264_hpel_filter_v_##cpuv( pixel *dst, pixel *src, int16_t *buf, intptr_t stride, intptr_t width);\
 void x264_hpel_filter_c_##cpuc( pixel *dst, int16_t *buf, intptr_t width );\
@@ -550,11 +745,15 @@ do\
 } while( 0 )
 #endif
 
+#define x264_mbtree_propagate_list_internal_ssse3 x264_template(mbtree_propagate_list_internal_ssse3)
 PROPAGATE_LIST(ssse3)
+#define x264_mbtree_propagate_list_internal_avx x264_template(mbtree_propagate_list_internal_avx)
 PROPAGATE_LIST(avx)
+#define x264_mbtree_propagate_list_internal_avx2 x264_template(mbtree_propagate_list_internal_avx2)
 PROPAGATE_LIST(avx2)
 
 #if ARCH_X86_64
+#define x264_mbtree_propagate_list_internal_avx512 x264_template(mbtree_propagate_list_internal_avx512)
 void x264_mbtree_propagate_list_internal_avx512( size_t len, uint16_t *ref_costs, int16_t (*mvs)[2], int16_t *propagate_amount,
                                                  uint16_t *lowres_costs, int bipred_weight, int mb_y,
                                                  int width, int height, int stride, int list_mask );
index 394fb7bb84267aeea1c5ee7547ef3835e2d2eab7..b4e6d1a066784298239ac0127e70fc5987bfbb71 100644 (file)
@@ -27,6 +27,7 @@
 #ifndef X264_I386_MC_H
 #define X264_I386_MC_H
 
+#define x264_mc_init_mmx x264_template(mc_init_mmx)
 void x264_mc_init_mmx( int cpu, x264_mc_functions_t *pf );
 
 #endif
index d6e7dee3b9909af41e4c355b941c2b7779136204..94df0f6286a41d96d51f1259eba7d9a5df703c1a 100644 (file)
@@ -33,6 +33,8 @@ cextern pw_pmpmpmpm
 SECTION .text
 INIT_MMX mmx2
 
+%if HIGH_BIT_DEPTH == 0
+
 %macro LOAD_DIFF_4x8P 1 ; dx
     LOAD_DIFF  m0, m7, none, [r0+%1],      [r2+%1]
     LOAD_DIFF  m1, m6, none, [r0+%1+r1],   [r2+%1+r3]
@@ -418,3 +420,4 @@ cglobal pixel_ssim_4x4x2_core, 0,5
     emms
     RET
 
+%endif ; !HIGH_BIT_DEPTH
index 1ce26b9edae9add776c58df87de08148075821df..b5de1634849429c18b0059243a043709a2039ed1 100644 (file)
@@ -4280,7 +4280,7 @@ cglobal pixel_hadamard_ac_%1x%2, 2,4,11
 
 ; instantiate satds
 
-%if ARCH_X86_64 == 0
+%if ARCH_X86_64 == 0 && HIGH_BIT_DEPTH == 0
 cextern pixel_sa8d_8x8_internal_mmx2
 INIT_MMX mmx2
 SA8D
index 56cfc5cbbf12cb7e732d40a69425914908d45025..949785f15a1ca592367c7f7ea95ae3e5003b8f40 100644 (file)
 #ifndef X264_I386_PIXEL_H
 #define X264_I386_PIXEL_H
 
+#define x264_pixel_ads1_avx x264_template(pixel_ads1_avx)
+#define x264_pixel_ads1_avx2 x264_template(pixel_ads1_avx2)
+#define x264_pixel_ads1_mmx2 x264_template(pixel_ads1_mmx2)
+#define x264_pixel_ads1_sse2 x264_template(pixel_ads1_sse2)
+#define x264_pixel_ads1_ssse3 x264_template(pixel_ads1_ssse3)
+#define x264_pixel_ads2_avx x264_template(pixel_ads2_avx)
+#define x264_pixel_ads2_avx2 x264_template(pixel_ads2_avx2)
+#define x264_pixel_ads2_mmx2 x264_template(pixel_ads2_mmx2)
+#define x264_pixel_ads2_sse2 x264_template(pixel_ads2_sse2)
+#define x264_pixel_ads2_ssse3 x264_template(pixel_ads2_ssse3)
+#define x264_pixel_ads4_avx x264_template(pixel_ads4_avx)
+#define x264_pixel_ads4_avx2 x264_template(pixel_ads4_avx2)
+#define x264_pixel_ads4_mmx2 x264_template(pixel_ads4_mmx2)
+#define x264_pixel_ads4_sse2 x264_template(pixel_ads4_sse2)
+#define x264_pixel_ads4_ssse3 x264_template(pixel_ads4_ssse3)
+#define x264_pixel_hadamard_ac_16x16_avx x264_template(pixel_hadamard_ac_16x16_avx)
+#define x264_pixel_hadamard_ac_16x16_avx2 x264_template(pixel_hadamard_ac_16x16_avx2)
+#define x264_pixel_hadamard_ac_16x16_mmx2 x264_template(pixel_hadamard_ac_16x16_mmx2)
+#define x264_pixel_hadamard_ac_16x16_sse2 x264_template(pixel_hadamard_ac_16x16_sse2)
+#define x264_pixel_hadamard_ac_16x16_sse4 x264_template(pixel_hadamard_ac_16x16_sse4)
+#define x264_pixel_hadamard_ac_16x16_ssse3 x264_template(pixel_hadamard_ac_16x16_ssse3)
+#define x264_pixel_hadamard_ac_16x16_ssse3_atom x264_template(pixel_hadamard_ac_16x16_ssse3_atom)
+#define x264_pixel_hadamard_ac_16x16_xop x264_template(pixel_hadamard_ac_16x16_xop)
+#define x264_pixel_hadamard_ac_16x8_avx x264_template(pixel_hadamard_ac_16x8_avx)
+#define x264_pixel_hadamard_ac_16x8_avx2 x264_template(pixel_hadamard_ac_16x8_avx2)
+#define x264_pixel_hadamard_ac_16x8_mmx2 x264_template(pixel_hadamard_ac_16x8_mmx2)
+#define x264_pixel_hadamard_ac_16x8_sse2 x264_template(pixel_hadamard_ac_16x8_sse2)
+#define x264_pixel_hadamard_ac_16x8_sse4 x264_template(pixel_hadamard_ac_16x8_sse4)
+#define x264_pixel_hadamard_ac_16x8_ssse3 x264_template(pixel_hadamard_ac_16x8_ssse3)
+#define x264_pixel_hadamard_ac_16x8_ssse3_atom x264_template(pixel_hadamard_ac_16x8_ssse3_atom)
+#define x264_pixel_hadamard_ac_16x8_xop x264_template(pixel_hadamard_ac_16x8_xop)
+#define x264_pixel_hadamard_ac_8x16_avx x264_template(pixel_hadamard_ac_8x16_avx)
+#define x264_pixel_hadamard_ac_8x16_mmx2 x264_template(pixel_hadamard_ac_8x16_mmx2)
+#define x264_pixel_hadamard_ac_8x16_sse2 x264_template(pixel_hadamard_ac_8x16_sse2)
+#define x264_pixel_hadamard_ac_8x16_sse4 x264_template(pixel_hadamard_ac_8x16_sse4)
+#define x264_pixel_hadamard_ac_8x16_ssse3 x264_template(pixel_hadamard_ac_8x16_ssse3)
+#define x264_pixel_hadamard_ac_8x16_ssse3_atom x264_template(pixel_hadamard_ac_8x16_ssse3_atom)
+#define x264_pixel_hadamard_ac_8x16_xop x264_template(pixel_hadamard_ac_8x16_xop)
+#define x264_pixel_hadamard_ac_8x8_avx x264_template(pixel_hadamard_ac_8x8_avx)
+#define x264_pixel_hadamard_ac_8x8_mmx2 x264_template(pixel_hadamard_ac_8x8_mmx2)
+#define x264_pixel_hadamard_ac_8x8_sse2 x264_template(pixel_hadamard_ac_8x8_sse2)
+#define x264_pixel_hadamard_ac_8x8_sse4 x264_template(pixel_hadamard_ac_8x8_sse4)
+#define x264_pixel_hadamard_ac_8x8_ssse3 x264_template(pixel_hadamard_ac_8x8_ssse3)
+#define x264_pixel_hadamard_ac_8x8_ssse3_atom x264_template(pixel_hadamard_ac_8x8_ssse3_atom)
+#define x264_pixel_hadamard_ac_8x8_xop x264_template(pixel_hadamard_ac_8x8_xop)
+#define x264_pixel_sa8d_16x16_mmx2 x264_template(pixel_sa8d_16x16_mmx2)
+#define x264_pixel_sa8d_16x16_avx x264_template(pixel_sa8d_16x16_avx)
+#define x264_pixel_sa8d_16x16_sse2 x264_template(pixel_sa8d_16x16_sse2)
+#define x264_pixel_sa8d_16x16_sse4 x264_template(pixel_sa8d_16x16_sse4)
+#define x264_pixel_sa8d_16x16_ssse3 x264_template(pixel_sa8d_16x16_ssse3)
+#define x264_pixel_sa8d_16x16_ssse3_atom x264_template(pixel_sa8d_16x16_ssse3_atom)
+#define x264_pixel_sa8d_16x16_xop x264_template(pixel_sa8d_16x16_xop)
+#define x264_pixel_sa8d_8x8_mmx2 x264_template(pixel_sa8d_8x8_mmx2)
+#define x264_pixel_sa8d_8x8_avx x264_template(pixel_sa8d_8x8_avx)
+#define x264_pixel_sa8d_8x8_avx2 x264_template(pixel_sa8d_8x8_avx2)
+#define x264_pixel_sa8d_8x8_avx512 x264_template(pixel_sa8d_8x8_avx512)
+#define x264_pixel_sa8d_8x8_sse2 x264_template(pixel_sa8d_8x8_sse2)
+#define x264_pixel_sa8d_8x8_sse4 x264_template(pixel_sa8d_8x8_sse4)
+#define x264_pixel_sa8d_8x8_ssse3 x264_template(pixel_sa8d_8x8_ssse3)
+#define x264_pixel_sa8d_8x8_ssse3_atom x264_template(pixel_sa8d_8x8_ssse3_atom)
+#define x264_pixel_sa8d_8x8_xop x264_template(pixel_sa8d_8x8_xop)
+#define x264_pixel_sad_16x16_avx2 x264_template(pixel_sad_16x16_avx2)
+#define x264_pixel_sad_16x16_avx512 x264_template(pixel_sad_16x16_avx512)
+#define x264_pixel_sad_16x16_cache32_mmx2 x264_template(pixel_sad_16x16_cache32_mmx2)
+#define x264_pixel_sad_16x16_cache64_mmx2 x264_template(pixel_sad_16x16_cache64_mmx2)
+#define x264_pixel_sad_16x16_cache64_sse2 x264_template(pixel_sad_16x16_cache64_sse2)
+#define x264_pixel_sad_16x16_cache64_ssse3 x264_template(pixel_sad_16x16_cache64_ssse3)
+#define x264_pixel_sad_16x16_mmx2 x264_template(pixel_sad_16x16_mmx2)
+#define x264_pixel_sad_16x16_sse2 x264_template(pixel_sad_16x16_sse2)
+#define x264_pixel_sad_16x16_sse2_aligned x264_template(pixel_sad_16x16_sse2_aligned)
+#define x264_pixel_sad_16x16_sse3 x264_template(pixel_sad_16x16_sse3)
+#define x264_pixel_sad_16x16_ssse3 x264_template(pixel_sad_16x16_ssse3)
+#define x264_pixel_sad_16x16_ssse3_aligned x264_template(pixel_sad_16x16_ssse3_aligned)
+#define x264_pixel_sad_16x8_avx2 x264_template(pixel_sad_16x8_avx2)
+#define x264_pixel_sad_16x8_avx512 x264_template(pixel_sad_16x8_avx512)
+#define x264_pixel_sad_16x8_cache32_mmx2 x264_template(pixel_sad_16x8_cache32_mmx2)
+#define x264_pixel_sad_16x8_cache64_mmx2 x264_template(pixel_sad_16x8_cache64_mmx2)
+#define x264_pixel_sad_16x8_cache64_sse2 x264_template(pixel_sad_16x8_cache64_sse2)
+#define x264_pixel_sad_16x8_cache64_ssse3 x264_template(pixel_sad_16x8_cache64_ssse3)
+#define x264_pixel_sad_16x8_mmx2 x264_template(pixel_sad_16x8_mmx2)
+#define x264_pixel_sad_16x8_sse2 x264_template(pixel_sad_16x8_sse2)
+#define x264_pixel_sad_16x8_sse2_aligned x264_template(pixel_sad_16x8_sse2_aligned)
+#define x264_pixel_sad_16x8_sse3 x264_template(pixel_sad_16x8_sse3)
+#define x264_pixel_sad_16x8_ssse3 x264_template(pixel_sad_16x8_ssse3)
+#define x264_pixel_sad_16x8_ssse3_aligned x264_template(pixel_sad_16x8_ssse3_aligned)
+#define x264_pixel_sad_4x16_avx512 x264_template(pixel_sad_4x16_avx512)
+#define x264_pixel_sad_4x16_mmx2 x264_template(pixel_sad_4x16_mmx2)
+#define x264_pixel_sad_4x4_avx512 x264_template(pixel_sad_4x4_avx512)
+#define x264_pixel_sad_4x4_mmx2 x264_template(pixel_sad_4x4_mmx2)
+#define x264_pixel_sad_4x4_ssse3 x264_template(pixel_sad_4x4_ssse3)
+#define x264_pixel_sad_4x8_avx512 x264_template(pixel_sad_4x8_avx512)
+#define x264_pixel_sad_4x8_mmx2 x264_template(pixel_sad_4x8_mmx2)
+#define x264_pixel_sad_4x8_ssse3 x264_template(pixel_sad_4x8_ssse3)
+#define x264_pixel_sad_8x16_avx512 x264_template(pixel_sad_8x16_avx512)
+#define x264_pixel_sad_8x16_cache32_mmx2 x264_template(pixel_sad_8x16_cache32_mmx2)
+#define x264_pixel_sad_8x16_cache64_mmx2 x264_template(pixel_sad_8x16_cache64_mmx2)
+#define x264_pixel_sad_8x16_mmx2 x264_template(pixel_sad_8x16_mmx2)
+#define x264_pixel_sad_8x16_sse2 x264_template(pixel_sad_8x16_sse2)
+#define x264_pixel_sad_8x16_sse2_aligned x264_template(pixel_sad_8x16_sse2_aligned)
+#define x264_pixel_sad_8x16_ssse3 x264_template(pixel_sad_8x16_ssse3)
+#define x264_pixel_sad_8x16_ssse3_aligned x264_template(pixel_sad_8x16_ssse3_aligned)
+#define x264_pixel_sad_8x4_avx512 x264_template(pixel_sad_8x4_avx512)
+#define x264_pixel_sad_8x4_cache32_mmx2 x264_template(pixel_sad_8x4_cache32_mmx2)
+#define x264_pixel_sad_8x4_cache64_mmx2 x264_template(pixel_sad_8x4_cache64_mmx2)
+#define x264_pixel_sad_8x4_mmx2 x264_template(pixel_sad_8x4_mmx2)
+#define x264_pixel_sad_8x4_sse2 x264_template(pixel_sad_8x4_sse2)
+#define x264_pixel_sad_8x4_ssse3 x264_template(pixel_sad_8x4_ssse3)
+#define x264_pixel_sad_8x8_avx512 x264_template(pixel_sad_8x8_avx512)
+#define x264_pixel_sad_8x8_cache32_mmx2 x264_template(pixel_sad_8x8_cache32_mmx2)
+#define x264_pixel_sad_8x8_cache64_mmx2 x264_template(pixel_sad_8x8_cache64_mmx2)
+#define x264_pixel_sad_8x8_mmx2 x264_template(pixel_sad_8x8_mmx2)
+#define x264_pixel_sad_8x8_sse2 x264_template(pixel_sad_8x8_sse2)
+#define x264_pixel_sad_8x8_sse2_aligned x264_template(pixel_sad_8x8_sse2_aligned)
+#define x264_pixel_sad_8x8_ssse3 x264_template(pixel_sad_8x8_ssse3)
+#define x264_pixel_sad_8x8_ssse3_aligned x264_template(pixel_sad_8x8_ssse3_aligned)
+#define x264_pixel_sad_x3_16x16_avx x264_template(pixel_sad_x3_16x16_avx)
+#define x264_pixel_sad_x3_16x16_avx2 x264_template(pixel_sad_x3_16x16_avx2)
+#define x264_pixel_sad_x3_16x16_avx512 x264_template(pixel_sad_x3_16x16_avx512)
+#define x264_pixel_sad_x3_16x16_cache32_mmx2 x264_template(pixel_sad_x3_16x16_cache32_mmx2)
+#define x264_pixel_sad_x3_16x16_cache64_mmx2 x264_template(pixel_sad_x3_16x16_cache64_mmx2)
+#define x264_pixel_sad_x3_16x16_cache64_sse2 x264_template(pixel_sad_x3_16x16_cache64_sse2)
+#define x264_pixel_sad_x3_16x16_cache64_ssse3 x264_template(pixel_sad_x3_16x16_cache64_ssse3)
+#define x264_pixel_sad_x3_16x16_mmx2 x264_template(pixel_sad_x3_16x16_mmx2)
+#define x264_pixel_sad_x3_16x16_sse2 x264_template(pixel_sad_x3_16x16_sse2)
+#define x264_pixel_sad_x3_16x16_sse3 x264_template(pixel_sad_x3_16x16_sse3)
+#define x264_pixel_sad_x3_16x16_ssse3 x264_template(pixel_sad_x3_16x16_ssse3)
+#define x264_pixel_sad_x3_16x16_xop x264_template(pixel_sad_x3_16x16_xop)
+#define x264_pixel_sad_x3_16x8_avx x264_template(pixel_sad_x3_16x8_avx)
+#define x264_pixel_sad_x3_16x8_avx2 x264_template(pixel_sad_x3_16x8_avx2)
+#define x264_pixel_sad_x3_16x8_avx512 x264_template(pixel_sad_x3_16x8_avx512)
+#define x264_pixel_sad_x3_16x8_cache32_mmx2 x264_template(pixel_sad_x3_16x8_cache32_mmx2)
+#define x264_pixel_sad_x3_16x8_cache64_mmx2 x264_template(pixel_sad_x3_16x8_cache64_mmx2)
+#define x264_pixel_sad_x3_16x8_cache64_sse2 x264_template(pixel_sad_x3_16x8_cache64_sse2)
+#define x264_pixel_sad_x3_16x8_cache64_ssse3 x264_template(pixel_sad_x3_16x8_cache64_ssse3)
+#define x264_pixel_sad_x3_16x8_mmx2 x264_template(pixel_sad_x3_16x8_mmx2)
+#define x264_pixel_sad_x3_16x8_sse2 x264_template(pixel_sad_x3_16x8_sse2)
+#define x264_pixel_sad_x3_16x8_sse3 x264_template(pixel_sad_x3_16x8_sse3)
+#define x264_pixel_sad_x3_16x8_ssse3 x264_template(pixel_sad_x3_16x8_ssse3)
+#define x264_pixel_sad_x3_16x8_xop x264_template(pixel_sad_x3_16x8_xop)
+#define x264_pixel_sad_x3_4x4_avx512 x264_template(pixel_sad_x3_4x4_avx512)
+#define x264_pixel_sad_x3_4x4_mmx2 x264_template(pixel_sad_x3_4x4_mmx2)
+#define x264_pixel_sad_x3_4x4_ssse3 x264_template(pixel_sad_x3_4x4_ssse3)
+#define x264_pixel_sad_x3_4x8_avx512 x264_template(pixel_sad_x3_4x8_avx512)
+#define x264_pixel_sad_x3_4x8_mmx2 x264_template(pixel_sad_x3_4x8_mmx2)
+#define x264_pixel_sad_x3_4x8_ssse3 x264_template(pixel_sad_x3_4x8_ssse3)
+#define x264_pixel_sad_x3_8x16_avx512 x264_template(pixel_sad_x3_8x16_avx512)
+#define x264_pixel_sad_x3_8x16_cache32_mmx2 x264_template(pixel_sad_x3_8x16_cache32_mmx2)
+#define x264_pixel_sad_x3_8x16_cache64_mmx2 x264_template(pixel_sad_x3_8x16_cache64_mmx2)
+#define x264_pixel_sad_x3_8x16_cache64_sse2 x264_template(pixel_sad_x3_8x16_cache64_sse2)
+#define x264_pixel_sad_x3_8x16_mmx2 x264_template(pixel_sad_x3_8x16_mmx2)
+#define x264_pixel_sad_x3_8x16_sse2 x264_template(pixel_sad_x3_8x16_sse2)
+#define x264_pixel_sad_x3_8x16_ssse3 x264_template(pixel_sad_x3_8x16_ssse3)
+#define x264_pixel_sad_x3_8x16_xop x264_template(pixel_sad_x3_8x16_xop)
+#define x264_pixel_sad_x3_8x4_avx512 x264_template(pixel_sad_x3_8x4_avx512)
+#define x264_pixel_sad_x3_8x4_mmx2 x264_template(pixel_sad_x3_8x4_mmx2)
+#define x264_pixel_sad_x3_8x4_sse2 x264_template(pixel_sad_x3_8x4_sse2)
+#define x264_pixel_sad_x3_8x4_ssse3 x264_template(pixel_sad_x3_8x4_ssse3)
+#define x264_pixel_sad_x3_8x4_xop x264_template(pixel_sad_x3_8x4_xop)
+#define x264_pixel_sad_x3_8x8_avx512 x264_template(pixel_sad_x3_8x8_avx512)
+#define x264_pixel_sad_x3_8x8_cache32_mmx2 x264_template(pixel_sad_x3_8x8_cache32_mmx2)
+#define x264_pixel_sad_x3_8x8_cache64_mmx2 x264_template(pixel_sad_x3_8x8_cache64_mmx2)
+#define x264_pixel_sad_x3_8x8_mmx2 x264_template(pixel_sad_x3_8x8_mmx2)
+#define x264_pixel_sad_x3_8x8_sse2 x264_template(pixel_sad_x3_8x8_sse2)
+#define x264_pixel_sad_x3_8x8_ssse3 x264_template(pixel_sad_x3_8x8_ssse3)
+#define x264_pixel_sad_x3_8x8_xop x264_template(pixel_sad_x3_8x8_xop)
+#define x264_pixel_sad_x4_16x16_avx x264_template(pixel_sad_x4_16x16_avx)
+#define x264_pixel_sad_x4_16x16_avx2 x264_template(pixel_sad_x4_16x16_avx2)
+#define x264_pixel_sad_x4_16x16_avx512 x264_template(pixel_sad_x4_16x16_avx512)
+#define x264_pixel_sad_x4_16x16_cache32_mmx2 x264_template(pixel_sad_x4_16x16_cache32_mmx2)
+#define x264_pixel_sad_x4_16x16_cache64_mmx2 x264_template(pixel_sad_x4_16x16_cache64_mmx2)
+#define x264_pixel_sad_x4_16x16_cache64_sse2 x264_template(pixel_sad_x4_16x16_cache64_sse2)
+#define x264_pixel_sad_x4_16x16_cache64_ssse3 x264_template(pixel_sad_x4_16x16_cache64_ssse3)
+#define x264_pixel_sad_x4_16x16_mmx2 x264_template(pixel_sad_x4_16x16_mmx2)
+#define x264_pixel_sad_x4_16x16_sse2 x264_template(pixel_sad_x4_16x16_sse2)
+#define x264_pixel_sad_x4_16x16_sse3 x264_template(pixel_sad_x4_16x16_sse3)
+#define x264_pixel_sad_x4_16x16_ssse3 x264_template(pixel_sad_x4_16x16_ssse3)
+#define x264_pixel_sad_x4_16x16_xop x264_template(pixel_sad_x4_16x16_xop)
+#define x264_pixel_sad_x4_16x8_avx x264_template(pixel_sad_x4_16x8_avx)
+#define x264_pixel_sad_x4_16x8_avx2 x264_template(pixel_sad_x4_16x8_avx2)
+#define x264_pixel_sad_x4_16x8_avx512 x264_template(pixel_sad_x4_16x8_avx512)
+#define x264_pixel_sad_x4_16x8_cache32_mmx2 x264_template(pixel_sad_x4_16x8_cache32_mmx2)
+#define x264_pixel_sad_x4_16x8_cache64_mmx2 x264_template(pixel_sad_x4_16x8_cache64_mmx2)
+#define x264_pixel_sad_x4_16x8_cache64_sse2 x264_template(pixel_sad_x4_16x8_cache64_sse2)
+#define x264_pixel_sad_x4_16x8_cache64_ssse3 x264_template(pixel_sad_x4_16x8_cache64_ssse3)
+#define x264_pixel_sad_x4_16x8_mmx2 x264_template(pixel_sad_x4_16x8_mmx2)
+#define x264_pixel_sad_x4_16x8_sse2 x264_template(pixel_sad_x4_16x8_sse2)
+#define x264_pixel_sad_x4_16x8_sse3 x264_template(pixel_sad_x4_16x8_sse3)
+#define x264_pixel_sad_x4_16x8_ssse3 x264_template(pixel_sad_x4_16x8_ssse3)
+#define x264_pixel_sad_x4_16x8_xop x264_template(pixel_sad_x4_16x8_xop)
+#define x264_pixel_sad_x4_4x4_avx512 x264_template(pixel_sad_x4_4x4_avx512)
+#define x264_pixel_sad_x4_4x4_mmx2 x264_template(pixel_sad_x4_4x4_mmx2)
+#define x264_pixel_sad_x4_4x4_ssse3 x264_template(pixel_sad_x4_4x4_ssse3)
+#define x264_pixel_sad_x4_4x8_avx512 x264_template(pixel_sad_x4_4x8_avx512)
+#define x264_pixel_sad_x4_4x8_mmx2 x264_template(pixel_sad_x4_4x8_mmx2)
+#define x264_pixel_sad_x4_4x8_ssse3 x264_template(pixel_sad_x4_4x8_ssse3)
+#define x264_pixel_sad_x4_8x16_avx512 x264_template(pixel_sad_x4_8x16_avx512)
+#define x264_pixel_sad_x4_8x16_cache32_mmx2 x264_template(pixel_sad_x4_8x16_cache32_mmx2)
+#define x264_pixel_sad_x4_8x16_cache64_mmx2 x264_template(pixel_sad_x4_8x16_cache64_mmx2)
+#define x264_pixel_sad_x4_8x16_cache64_sse2 x264_template(pixel_sad_x4_8x16_cache64_sse2)
+#define x264_pixel_sad_x4_8x16_mmx2 x264_template(pixel_sad_x4_8x16_mmx2)
+#define x264_pixel_sad_x4_8x16_sse2 x264_template(pixel_sad_x4_8x16_sse2)
+#define x264_pixel_sad_x4_8x16_ssse3 x264_template(pixel_sad_x4_8x16_ssse3)
+#define x264_pixel_sad_x4_8x16_xop x264_template(pixel_sad_x4_8x16_xop)
+#define x264_pixel_sad_x4_8x4_avx512 x264_template(pixel_sad_x4_8x4_avx512)
+#define x264_pixel_sad_x4_8x4_mmx2 x264_template(pixel_sad_x4_8x4_mmx2)
+#define x264_pixel_sad_x4_8x4_sse2 x264_template(pixel_sad_x4_8x4_sse2)
+#define x264_pixel_sad_x4_8x4_ssse3 x264_template(pixel_sad_x4_8x4_ssse3)
+#define x264_pixel_sad_x4_8x4_xop x264_template(pixel_sad_x4_8x4_xop)
+#define x264_pixel_sad_x4_8x8_avx512 x264_template(pixel_sad_x4_8x8_avx512)
+#define x264_pixel_sad_x4_8x8_cache32_mmx2 x264_template(pixel_sad_x4_8x8_cache32_mmx2)
+#define x264_pixel_sad_x4_8x8_cache64_mmx2 x264_template(pixel_sad_x4_8x8_cache64_mmx2)
+#define x264_pixel_sad_x4_8x8_mmx2 x264_template(pixel_sad_x4_8x8_mmx2)
+#define x264_pixel_sad_x4_8x8_sse2 x264_template(pixel_sad_x4_8x8_sse2)
+#define x264_pixel_sad_x4_8x8_ssse3 x264_template(pixel_sad_x4_8x8_ssse3)
+#define x264_pixel_sad_x4_8x8_xop x264_template(pixel_sad_x4_8x8_xop)
+#define x264_pixel_satd_16x16_avx x264_template(pixel_satd_16x16_avx)
+#define x264_pixel_satd_16x16_avx2 x264_template(pixel_satd_16x16_avx2)
+#define x264_pixel_satd_16x16_avx512 x264_template(pixel_satd_16x16_avx512)
+#define x264_pixel_satd_16x16_mmx2 x264_template(pixel_satd_16x16_mmx2)
+#define x264_pixel_satd_16x16_sse2 x264_template(pixel_satd_16x16_sse2)
+#define x264_pixel_satd_16x16_sse4 x264_template(pixel_satd_16x16_sse4)
+#define x264_pixel_satd_16x16_ssse3 x264_template(pixel_satd_16x16_ssse3)
+#define x264_pixel_satd_16x16_ssse3_atom x264_template(pixel_satd_16x16_ssse3_atom)
+#define x264_pixel_satd_16x16_xop x264_template(pixel_satd_16x16_xop)
+#define x264_pixel_satd_16x8_avx x264_template(pixel_satd_16x8_avx)
+#define x264_pixel_satd_16x8_avx2 x264_template(pixel_satd_16x8_avx2)
+#define x264_pixel_satd_16x8_avx512 x264_template(pixel_satd_16x8_avx512)
+#define x264_pixel_satd_16x8_mmx2 x264_template(pixel_satd_16x8_mmx2)
+#define x264_pixel_satd_16x8_sse2 x264_template(pixel_satd_16x8_sse2)
+#define x264_pixel_satd_16x8_sse4 x264_template(pixel_satd_16x8_sse4)
+#define x264_pixel_satd_16x8_ssse3 x264_template(pixel_satd_16x8_ssse3)
+#define x264_pixel_satd_16x8_ssse3_atom x264_template(pixel_satd_16x8_ssse3_atom)
+#define x264_pixel_satd_16x8_xop x264_template(pixel_satd_16x8_xop)
+#define x264_pixel_satd_4x16_avx x264_template(pixel_satd_4x16_avx)
+#define x264_pixel_satd_4x16_avx512 x264_template(pixel_satd_4x16_avx512)
+#define x264_pixel_satd_4x16_mmx2 x264_template(pixel_satd_4x16_mmx2)
+#define x264_pixel_satd_4x16_sse2 x264_template(pixel_satd_4x16_sse2)
+#define x264_pixel_satd_4x16_sse4 x264_template(pixel_satd_4x16_sse4)
+#define x264_pixel_satd_4x16_ssse3 x264_template(pixel_satd_4x16_ssse3)
+#define x264_pixel_satd_4x16_ssse3_atom x264_template(pixel_satd_4x16_ssse3_atom)
+#define x264_pixel_satd_4x4_avx x264_template(pixel_satd_4x4_avx)
+#define x264_pixel_satd_4x4_avx512 x264_template(pixel_satd_4x4_avx512)
+#define x264_pixel_satd_4x4_mmx2 x264_template(pixel_satd_4x4_mmx2)
+#define x264_pixel_satd_4x4_sse4 x264_template(pixel_satd_4x4_sse4)
+#define x264_pixel_satd_4x4_ssse3 x264_template(pixel_satd_4x4_ssse3)
+#define x264_pixel_satd_4x4_xop x264_template(pixel_satd_4x4_xop)
+#define x264_pixel_satd_4x8_avx x264_template(pixel_satd_4x8_avx)
+#define x264_pixel_satd_4x8_avx512 x264_template(pixel_satd_4x8_avx512)
+#define x264_pixel_satd_4x8_mmx2 x264_template(pixel_satd_4x8_mmx2)
+#define x264_pixel_satd_4x8_sse2 x264_template(pixel_satd_4x8_sse2)
+#define x264_pixel_satd_4x8_sse4 x264_template(pixel_satd_4x8_sse4)
+#define x264_pixel_satd_4x8_ssse3 x264_template(pixel_satd_4x8_ssse3)
+#define x264_pixel_satd_4x8_ssse3_atom x264_template(pixel_satd_4x8_ssse3_atom)
+#define x264_pixel_satd_4x8_xop x264_template(pixel_satd_4x8_xop)
+#define x264_pixel_satd_8x16_avx x264_template(pixel_satd_8x16_avx)
+#define x264_pixel_satd_8x16_avx2 x264_template(pixel_satd_8x16_avx2)
+#define x264_pixel_satd_8x16_avx512 x264_template(pixel_satd_8x16_avx512)
+#define x264_pixel_satd_8x16_mmx2 x264_template(pixel_satd_8x16_mmx2)
+#define x264_pixel_satd_8x16_sse2 x264_template(pixel_satd_8x16_sse2)
+#define x264_pixel_satd_8x16_sse4 x264_template(pixel_satd_8x16_sse4)
+#define x264_pixel_satd_8x16_ssse3 x264_template(pixel_satd_8x16_ssse3)
+#define x264_pixel_satd_8x16_ssse3_atom x264_template(pixel_satd_8x16_ssse3_atom)
+#define x264_pixel_satd_8x16_xop x264_template(pixel_satd_8x16_xop)
+#define x264_pixel_satd_8x4_avx x264_template(pixel_satd_8x4_avx)
+#define x264_pixel_satd_8x4_avx512 x264_template(pixel_satd_8x4_avx512)
+#define x264_pixel_satd_8x4_mmx2 x264_template(pixel_satd_8x4_mmx2)
+#define x264_pixel_satd_8x4_sse2 x264_template(pixel_satd_8x4_sse2)
+#define x264_pixel_satd_8x4_sse4 x264_template(pixel_satd_8x4_sse4)
+#define x264_pixel_satd_8x4_ssse3 x264_template(pixel_satd_8x4_ssse3)
+#define x264_pixel_satd_8x4_ssse3_atom x264_template(pixel_satd_8x4_ssse3_atom)
+#define x264_pixel_satd_8x4_xop x264_template(pixel_satd_8x4_xop)
+#define x264_pixel_satd_8x8_avx x264_template(pixel_satd_8x8_avx)
+#define x264_pixel_satd_8x8_avx2 x264_template(pixel_satd_8x8_avx2)
+#define x264_pixel_satd_8x8_avx512 x264_template(pixel_satd_8x8_avx512)
+#define x264_pixel_satd_8x8_mmx2 x264_template(pixel_satd_8x8_mmx2)
+#define x264_pixel_satd_8x8_sse2 x264_template(pixel_satd_8x8_sse2)
+#define x264_pixel_satd_8x8_sse4 x264_template(pixel_satd_8x8_sse4)
+#define x264_pixel_satd_8x8_ssse3 x264_template(pixel_satd_8x8_ssse3)
+#define x264_pixel_satd_8x8_ssse3_atom x264_template(pixel_satd_8x8_ssse3_atom)
+#define x264_pixel_satd_8x8_xop x264_template(pixel_satd_8x8_xop)
+#define x264_pixel_ssd_16x16_avx x264_template(pixel_ssd_16x16_avx)
+#define x264_pixel_ssd_16x16_avx2 x264_template(pixel_ssd_16x16_avx2)
+#define x264_pixel_ssd_16x16_mmx x264_template(pixel_ssd_16x16_mmx)
+#define x264_pixel_ssd_16x16_mmx2 x264_template(pixel_ssd_16x16_mmx2)
+#define x264_pixel_ssd_16x16_sse2 x264_template(pixel_ssd_16x16_sse2)
+#define x264_pixel_ssd_16x16_sse2slow x264_template(pixel_ssd_16x16_sse2slow)
+#define x264_pixel_ssd_16x16_ssse3 x264_template(pixel_ssd_16x16_ssse3)
+#define x264_pixel_ssd_16x16_xop x264_template(pixel_ssd_16x16_xop)
+#define x264_pixel_ssd_16x8_avx x264_template(pixel_ssd_16x8_avx)
+#define x264_pixel_ssd_16x8_avx2 x264_template(pixel_ssd_16x8_avx2)
+#define x264_pixel_ssd_16x8_mmx x264_template(pixel_ssd_16x8_mmx)
+#define x264_pixel_ssd_16x8_mmx2 x264_template(pixel_ssd_16x8_mmx2)
+#define x264_pixel_ssd_16x8_sse2 x264_template(pixel_ssd_16x8_sse2)
+#define x264_pixel_ssd_16x8_sse2slow x264_template(pixel_ssd_16x8_sse2slow)
+#define x264_pixel_ssd_16x8_ssse3 x264_template(pixel_ssd_16x8_ssse3)
+#define x264_pixel_ssd_16x8_xop x264_template(pixel_ssd_16x8_xop)
+#define x264_pixel_ssd_4x16_mmx x264_template(pixel_ssd_4x16_mmx)
+#define x264_pixel_ssd_4x16_mmx2 x264_template(pixel_ssd_4x16_mmx2)
+#define x264_pixel_ssd_4x16_ssse3 x264_template(pixel_ssd_4x16_ssse3)
+#define x264_pixel_ssd_4x4_mmx x264_template(pixel_ssd_4x4_mmx)
+#define x264_pixel_ssd_4x4_mmx2 x264_template(pixel_ssd_4x4_mmx2)
+#define x264_pixel_ssd_4x4_ssse3 x264_template(pixel_ssd_4x4_ssse3)
+#define x264_pixel_ssd_4x8_mmx x264_template(pixel_ssd_4x8_mmx)
+#define x264_pixel_ssd_4x8_mmx2 x264_template(pixel_ssd_4x8_mmx2)
+#define x264_pixel_ssd_4x8_ssse3 x264_template(pixel_ssd_4x8_ssse3)
+#define x264_pixel_ssd_8x16_avx x264_template(pixel_ssd_8x16_avx)
+#define x264_pixel_ssd_8x16_mmx x264_template(pixel_ssd_8x16_mmx)
+#define x264_pixel_ssd_8x16_mmx2 x264_template(pixel_ssd_8x16_mmx2)
+#define x264_pixel_ssd_8x16_sse2 x264_template(pixel_ssd_8x16_sse2)
+#define x264_pixel_ssd_8x16_sse2slow x264_template(pixel_ssd_8x16_sse2slow)
+#define x264_pixel_ssd_8x16_ssse3 x264_template(pixel_ssd_8x16_ssse3)
+#define x264_pixel_ssd_8x16_xop x264_template(pixel_ssd_8x16_xop)
+#define x264_pixel_ssd_8x4_avx x264_template(pixel_ssd_8x4_avx)
+#define x264_pixel_ssd_8x4_mmx x264_template(pixel_ssd_8x4_mmx)
+#define x264_pixel_ssd_8x4_mmx2 x264_template(pixel_ssd_8x4_mmx2)
+#define x264_pixel_ssd_8x4_sse2 x264_template(pixel_ssd_8x4_sse2)
+#define x264_pixel_ssd_8x4_sse2slow x264_template(pixel_ssd_8x4_sse2slow)
+#define x264_pixel_ssd_8x4_ssse3 x264_template(pixel_ssd_8x4_ssse3)
+#define x264_pixel_ssd_8x4_xop x264_template(pixel_ssd_8x4_xop)
+#define x264_pixel_ssd_8x8_avx x264_template(pixel_ssd_8x8_avx)
+#define x264_pixel_ssd_8x8_mmx x264_template(pixel_ssd_8x8_mmx)
+#define x264_pixel_ssd_8x8_mmx2 x264_template(pixel_ssd_8x8_mmx2)
+#define x264_pixel_ssd_8x8_sse2 x264_template(pixel_ssd_8x8_sse2)
+#define x264_pixel_ssd_8x8_sse2slow x264_template(pixel_ssd_8x8_sse2slow)
+#define x264_pixel_ssd_8x8_ssse3 x264_template(pixel_ssd_8x8_ssse3)
+#define x264_pixel_ssd_8x8_xop x264_template(pixel_ssd_8x8_xop)
+#define x264_pixel_var_16x16_avx x264_template(pixel_var_16x16_avx)
+#define x264_pixel_var_16x16_avx2 x264_template(pixel_var_16x16_avx2)
+#define x264_pixel_var_16x16_avx512 x264_template(pixel_var_16x16_avx512)
+#define x264_pixel_var_16x16_sse2 x264_template(pixel_var_16x16_sse2)
+#define x264_pixel_var_8x16_avx x264_template(pixel_var_8x16_avx)
+#define x264_pixel_var_8x16_avx512 x264_template(pixel_var_8x16_avx512)
+#define x264_pixel_var_8x16_sse2 x264_template(pixel_var_8x16_sse2)
+#define x264_pixel_var_8x8_avx x264_template(pixel_var_8x8_avx)
+#define x264_pixel_var_8x8_avx512 x264_template(pixel_var_8x8_avx512)
+#define x264_pixel_var_8x8_sse2 x264_template(pixel_var_8x8_sse2)
 #define DECL_PIXELS( ret, name, suffix, args ) \
     ret x264_pixel_##name##_16x16_##suffix args;\
     ret x264_pixel_##name##_16x8_##suffix args;\
@@ -110,86 +446,153 @@ DECL_PIXELS( uint64_t, hadamard_ac, xop,   ( pixel *pix, intptr_t i_stride ))
 DECL_PIXELS( uint64_t, hadamard_ac, avx2,  ( pixel *pix, intptr_t i_stride ))
 
 
+#define x264_intra_satd_x3_4x4_mmx2 x264_template(intra_satd_x3_4x4_mmx2)
 void x264_intra_satd_x3_4x4_mmx2   ( pixel   *, pixel   *, int * );
-void x264_intra_sad_x3_4x4_mmx2    ( pixel   *, pixel   *, int * );
-void x264_intra_sad_x3_4x4_sse2    ( pixel   *, pixel   *, int * );
-void x264_intra_sad_x3_4x4_ssse3   ( pixel   *, pixel   *, int * );
-void x264_intra_sad_x3_4x4_avx     ( pixel   *, pixel   *, int * );
+#define x264_intra_sad_x3_4x4_mmx2 x264_template(intra_sad_x3_4x4_mmx2)
+void x264_intra_sad_x3_4x4_mmx2    ( uint8_t *, uint8_t *, int * );
+#define x264_intra_sad_x3_4x4_sse2 x264_template(intra_sad_x3_4x4_sse2)
+void x264_intra_sad_x3_4x4_sse2    ( uint16_t*, uint16_t*, int * );
+#define x264_intra_sad_x3_4x4_ssse3 x264_template(intra_sad_x3_4x4_ssse3)
+void x264_intra_sad_x3_4x4_ssse3   ( uint16_t*, uint16_t*, int * );
+#define x264_intra_sad_x3_4x4_avx x264_template(intra_sad_x3_4x4_avx)
+void x264_intra_sad_x3_4x4_avx     ( uint16_t*, uint16_t*, int * );
+#define x264_intra_satd_x3_8x8c_mmx2 x264_template(intra_satd_x3_8x8c_mmx2)
 void x264_intra_satd_x3_8x8c_mmx2  ( pixel   *, pixel   *, int * );
+#define x264_intra_satd_x3_8x8c_ssse3 x264_template(intra_satd_x3_8x8c_ssse3)
 void x264_intra_satd_x3_8x8c_ssse3 ( uint8_t *, uint8_t *, int * );
-void x264_intra_sad_x3_8x8c_mmx2   ( pixel   *, pixel   *, int * );
-void x264_intra_sad_x3_8x8c_sse2   ( pixel   *, pixel   *, int * );
-void x264_intra_sad_x3_8x8c_ssse3  ( pixel   *, pixel   *, int * );
-void x264_intra_sad_x3_8x8c_avx2   ( pixel   *, pixel   *, int * );
+#define x264_intra_sad_x3_8x8c_mmx2 x264_template(intra_sad_x3_8x8c_mmx2)
+void x264_intra_sad_x3_8x8c_mmx2   ( uint8_t *, uint8_t *, int * );
+#define x264_intra_sad_x3_8x8c_ssse3 x264_template(intra_sad_x3_8x8c_ssse3)
+void x264_intra_sad_x3_8x8c_ssse3  ( uint8_t *, uint8_t *, int * );
+#define x264_intra_sad_x3_8x8c_avx2 x264_template(intra_sad_x3_8x8c_avx2)
+void x264_intra_sad_x3_8x8c_avx2   ( uint8_t *, uint8_t *, int * );
+#define x264_intra_satd_x3_16x16_mmx2 x264_template(intra_satd_x3_16x16_mmx2)
 void x264_intra_satd_x3_16x16_mmx2 ( pixel   *, pixel   *, int * );
+#define x264_intra_satd_x3_16x16_ssse3 x264_template(intra_satd_x3_16x16_ssse3)
 void x264_intra_satd_x3_16x16_ssse3( uint8_t *, uint8_t *, int * );
-void x264_intra_sad_x3_16x16_mmx2  ( pixel   *, pixel   *, int * );
-void x264_intra_sad_x3_16x16_sse2  ( pixel   *, pixel   *, int * );
-void x264_intra_sad_x3_16x16_ssse3 ( pixel   *, pixel   *, int * );
-void x264_intra_sad_x3_16x16_avx2  ( pixel   *, pixel   *, int * );
+#define x264_intra_sad_x3_16x16_mmx2 x264_template(intra_sad_x3_16x16_mmx2)
+void x264_intra_sad_x3_16x16_mmx2  ( uint8_t *, uint8_t *, int * );
+#define x264_intra_sad_x3_16x16_sse2 x264_template(intra_sad_x3_16x16_sse2)
+void x264_intra_sad_x3_16x16_sse2  ( uint8_t *, uint8_t *, int * );
+#define x264_intra_sad_x3_16x16_ssse3 x264_template(intra_sad_x3_16x16_ssse3)
+void x264_intra_sad_x3_16x16_ssse3 ( uint8_t *, uint8_t *, int * );
+#define x264_intra_sad_x3_16x16_avx2 x264_template(intra_sad_x3_16x16_avx2)
+void x264_intra_sad_x3_16x16_avx2  ( uint8_t *, uint8_t *, int * );
+#define x264_intra_sa8d_x3_8x8_mmx2 x264_template(intra_sa8d_x3_8x8_mmx2)
 void x264_intra_sa8d_x3_8x8_mmx2   ( uint8_t *, uint8_t *, int * );
-void x264_intra_sa8d_x3_8x8_sse2   ( pixel   *, pixel   *, int * );
-void x264_intra_sad_x3_8x8_mmx2    ( pixel   *, pixel   *, int * );
-void x264_intra_sad_x3_8x8_sse2    ( pixel   *, pixel   *, int * );
-void x264_intra_sad_x3_8x8_ssse3   ( pixel   *, pixel   *, int * );
+#define x264_intra_sa8d_x3_8x8_sse2 x264_template(intra_sa8d_x3_8x8_sse2)
+void x264_intra_sa8d_x3_8x8_sse2   ( uint8_t *, uint8_t *, int * );
+#define x264_intra_sad_x3_8x8_mmx2 x264_template(intra_sad_x3_8x8_mmx2)
+void x264_intra_sad_x3_8x8_mmx2    ( uint8_t *, uint8_t *, int * );
+#define x264_intra_sad_x3_8x8_sse2 x264_template(intra_sad_x3_8x8_sse2)
+void x264_intra_sad_x3_8x8_sse2    ( uint16_t*, uint16_t*, int * );
+#define x264_intra_sad_x3_8x8_ssse3 x264_template(intra_sad_x3_8x8_ssse3)
+void x264_intra_sad_x3_8x8_ssse3   ( uint16_t*, uint16_t*, int * );
+#define x264_intra_sad_x3_8x8_avx2 x264_template(intra_sad_x3_8x8_avx2)
 void x264_intra_sad_x3_8x8_avx2    ( uint16_t*, uint16_t*, int * );
+#define x264_intra_satd_x9_4x4_ssse3 x264_template(intra_satd_x9_4x4_ssse3)
 int x264_intra_satd_x9_4x4_ssse3( uint8_t *, uint8_t *, uint16_t * );
+#define x264_intra_satd_x9_4x4_sse4 x264_template(intra_satd_x9_4x4_sse4)
 int x264_intra_satd_x9_4x4_sse4 ( uint8_t *, uint8_t *, uint16_t * );
+#define x264_intra_satd_x9_4x4_avx x264_template(intra_satd_x9_4x4_avx)
 int x264_intra_satd_x9_4x4_avx  ( uint8_t *, uint8_t *, uint16_t * );
+#define x264_intra_satd_x9_4x4_xop x264_template(intra_satd_x9_4x4_xop)
 int x264_intra_satd_x9_4x4_xop  ( uint8_t *, uint8_t *, uint16_t * );
+#define x264_intra_sad_x9_4x4_ssse3 x264_template(intra_sad_x9_4x4_ssse3)
 int x264_intra_sad_x9_4x4_ssse3 ( uint8_t *, uint8_t *, uint16_t * );
+#define x264_intra_sad_x9_4x4_sse4 x264_template(intra_sad_x9_4x4_sse4)
 int x264_intra_sad_x9_4x4_sse4  ( uint8_t *, uint8_t *, uint16_t * );
+#define x264_intra_sad_x9_4x4_avx x264_template(intra_sad_x9_4x4_avx)
 int x264_intra_sad_x9_4x4_avx   ( uint8_t *, uint8_t *, uint16_t * );
+#define x264_intra_sa8d_x9_8x8_ssse3 x264_template(intra_sa8d_x9_8x8_ssse3)
 int x264_intra_sa8d_x9_8x8_ssse3( uint8_t *, uint8_t *, uint8_t *, uint16_t *, uint16_t * );
+#define x264_intra_sa8d_x9_8x8_sse4 x264_template(intra_sa8d_x9_8x8_sse4)
 int x264_intra_sa8d_x9_8x8_sse4 ( uint8_t *, uint8_t *, uint8_t *, uint16_t *, uint16_t * );
+#define x264_intra_sa8d_x9_8x8_avx x264_template(intra_sa8d_x9_8x8_avx)
 int x264_intra_sa8d_x9_8x8_avx  ( uint8_t *, uint8_t *, uint8_t *, uint16_t *, uint16_t * );
+#define x264_intra_sad_x9_8x8_ssse3 x264_template(intra_sad_x9_8x8_ssse3)
 int x264_intra_sad_x9_8x8_ssse3 ( uint8_t *, uint8_t *, uint8_t *, uint16_t *, uint16_t * );
+#define x264_intra_sad_x9_8x8_sse4 x264_template(intra_sad_x9_8x8_sse4)
 int x264_intra_sad_x9_8x8_sse4  ( uint8_t *, uint8_t *, uint8_t *, uint16_t *, uint16_t * );
+#define x264_intra_sad_x9_8x8_avx x264_template(intra_sad_x9_8x8_avx)
 int x264_intra_sad_x9_8x8_avx   ( uint8_t *, uint8_t *, uint8_t *, uint16_t *, uint16_t * );
+#define x264_intra_sad_x9_8x8_avx2 x264_template(intra_sad_x9_8x8_avx2)
 int x264_intra_sad_x9_8x8_avx2  ( uint8_t *, uint8_t *, uint8_t *, uint16_t *, uint16_t * );
 
+#define x264_pixel_ssd_nv12_core_sse2 x264_template(pixel_ssd_nv12_core_sse2)
 void x264_pixel_ssd_nv12_core_sse2( pixel *pixuv1, intptr_t stride1,
                                     pixel *pixuv2, intptr_t stride2, int width,
                                     int height, uint64_t *ssd_u, uint64_t *ssd_v );
+#define x264_pixel_ssd_nv12_core_avx x264_template(pixel_ssd_nv12_core_avx)
 void x264_pixel_ssd_nv12_core_avx ( pixel *pixuv1, intptr_t stride1,
                                     pixel *pixuv2, intptr_t stride2, int width,
                                     int height, uint64_t *ssd_u, uint64_t *ssd_v );
+#define x264_pixel_ssd_nv12_core_xop x264_template(pixel_ssd_nv12_core_xop)
 void x264_pixel_ssd_nv12_core_xop ( pixel *pixuv1, intptr_t stride1,
                                     pixel *pixuv2, intptr_t stride2, int width,
                                     int height, uint64_t *ssd_u, uint64_t *ssd_v );
+#define x264_pixel_ssd_nv12_core_avx2 x264_template(pixel_ssd_nv12_core_avx2)
 void x264_pixel_ssd_nv12_core_avx2( pixel *pixuv1, intptr_t stride1,
                                     pixel *pixuv2, intptr_t stride2, int width,
                                     int height, uint64_t *ssd_u, uint64_t *ssd_v );
+#define x264_pixel_ssim_4x4x2_core_mmx2 x264_template(pixel_ssim_4x4x2_core_mmx2)
 void x264_pixel_ssim_4x4x2_core_mmx2( const uint8_t *pix1, intptr_t stride1,
                                       const uint8_t *pix2, intptr_t stride2, int sums[2][4] );
+#define x264_pixel_ssim_4x4x2_core_sse2 x264_template(pixel_ssim_4x4x2_core_sse2)
 void x264_pixel_ssim_4x4x2_core_sse2( const pixel *pix1, intptr_t stride1,
                                       const pixel *pix2, intptr_t stride2, int sums[2][4] );
+#define x264_pixel_ssim_4x4x2_core_avx x264_template(pixel_ssim_4x4x2_core_avx)
 void x264_pixel_ssim_4x4x2_core_avx ( const pixel *pix1, intptr_t stride1,
                                       const pixel *pix2, intptr_t stride2, int sums[2][4] );
+#define x264_pixel_ssim_end4_sse2 x264_template(pixel_ssim_end4_sse2)
 float x264_pixel_ssim_end4_sse2( int sum0[5][4], int sum1[5][4], int width );
+#define x264_pixel_ssim_end4_avx x264_template(pixel_ssim_end4_avx)
 float x264_pixel_ssim_end4_avx ( int sum0[5][4], int sum1[5][4], int width );
+#define x264_pixel_var2_8x8_sse2 x264_template(pixel_var2_8x8_sse2)
 int  x264_pixel_var2_8x8_sse2   ( pixel   *fenc, pixel   *fdec, int ssd[2] );
+#define x264_pixel_var2_8x8_ssse3 x264_template(pixel_var2_8x8_ssse3)
 int  x264_pixel_var2_8x8_ssse3  ( uint8_t *fenc, uint8_t *fdec, int ssd[2] );
+#define x264_pixel_var2_8x8_avx2 x264_template(pixel_var2_8x8_avx2)
 int  x264_pixel_var2_8x8_avx2   ( pixel   *fenc, pixel   *fdec, int ssd[2] );
+#define x264_pixel_var2_8x8_avx512 x264_template(pixel_var2_8x8_avx512)
 int  x264_pixel_var2_8x8_avx512 ( pixel   *fenc, pixel   *fdec, int ssd[2] );
+#define x264_pixel_var2_8x16_sse2 x264_template(pixel_var2_8x16_sse2)
 int  x264_pixel_var2_8x16_sse2  ( pixel   *fenc, pixel   *fdec, int ssd[2] );
+#define x264_pixel_var2_8x16_ssse3 x264_template(pixel_var2_8x16_ssse3)
 int  x264_pixel_var2_8x16_ssse3 ( uint8_t *fenc, uint8_t *fdec, int ssd[2] );
+#define x264_pixel_var2_8x16_avx2 x264_template(pixel_var2_8x16_avx2)
 int  x264_pixel_var2_8x16_avx2  ( pixel   *fenc, pixel   *fdec, int ssd[2] );
+#define x264_pixel_var2_8x16_avx512 x264_template(pixel_var2_8x16_avx512)
 int  x264_pixel_var2_8x16_avx512( pixel   *fenc, pixel   *fdec, int ssd[2] );
+#define x264_pixel_vsad_mmx2 x264_template(pixel_vsad_mmx2)
 int  x264_pixel_vsad_mmx2 ( pixel *src, intptr_t stride, int height );
+#define x264_pixel_vsad_sse2 x264_template(pixel_vsad_sse2)
 int  x264_pixel_vsad_sse2 ( pixel *src, intptr_t stride, int height );
+#define x264_pixel_vsad_ssse3 x264_template(pixel_vsad_ssse3)
 int  x264_pixel_vsad_ssse3( pixel *src, intptr_t stride, int height );
+#define x264_pixel_vsad_xop x264_template(pixel_vsad_xop)
 int  x264_pixel_vsad_xop  ( pixel *src, intptr_t stride, int height );
+#define x264_pixel_vsad_avx2 x264_template(pixel_vsad_avx2)
 int  x264_pixel_vsad_avx2 ( uint16_t *src, intptr_t stride, int height );
+#define x264_pixel_asd8_sse2 x264_template(pixel_asd8_sse2)
 int x264_pixel_asd8_sse2 ( pixel *pix1, intptr_t stride1, pixel *pix2, intptr_t stride2, int height );
+#define x264_pixel_asd8_ssse3 x264_template(pixel_asd8_ssse3)
 int x264_pixel_asd8_ssse3( pixel *pix1, intptr_t stride1, pixel *pix2, intptr_t stride2, int height );
+#define x264_pixel_asd8_xop x264_template(pixel_asd8_xop)
 int x264_pixel_asd8_xop  ( pixel *pix1, intptr_t stride1, pixel *pix2, intptr_t stride2, int height );
+#define x264_pixel_sa8d_satd_16x16_sse2 x264_template(pixel_sa8d_satd_16x16_sse2)
 uint64_t x264_pixel_sa8d_satd_16x16_sse2      ( pixel *pix1, intptr_t stride1, pixel *pix2, intptr_t stride2 );
+#define x264_pixel_sa8d_satd_16x16_ssse3 x264_template(pixel_sa8d_satd_16x16_ssse3)
 uint64_t x264_pixel_sa8d_satd_16x16_ssse3     ( pixel *pix1, intptr_t stride1, pixel *pix2, intptr_t stride2 );
+#define x264_pixel_sa8d_satd_16x16_ssse3_atom x264_template(pixel_sa8d_satd_16x16_ssse3_atom)
 uint64_t x264_pixel_sa8d_satd_16x16_ssse3_atom( pixel *pix1, intptr_t stride1, pixel *pix2, intptr_t stride2 );
+#define x264_pixel_sa8d_satd_16x16_sse4 x264_template(pixel_sa8d_satd_16x16_sse4)
 uint64_t x264_pixel_sa8d_satd_16x16_sse4      ( pixel *pix1, intptr_t stride1, pixel *pix2, intptr_t stride2 );
+#define x264_pixel_sa8d_satd_16x16_avx x264_template(pixel_sa8d_satd_16x16_avx)
 uint64_t x264_pixel_sa8d_satd_16x16_avx       ( pixel *pix1, intptr_t stride1, pixel *pix2, intptr_t stride2 );
+#define x264_pixel_sa8d_satd_16x16_xop x264_template(pixel_sa8d_satd_16x16_xop)
 uint64_t x264_pixel_sa8d_satd_16x16_xop       ( pixel *pix1, intptr_t stride1, pixel *pix2, intptr_t stride2 );
+#define x264_pixel_sa8d_satd_16x16_avx2 x264_template(pixel_sa8d_satd_16x16_avx2)
 uint64_t x264_pixel_sa8d_satd_16x16_avx2      ( pixel *pix1, intptr_t stride1, pixel *pix2, intptr_t stride2 );
 
 
index 9f9052c238f149ac23a8f8aeb181036f86771476..ca9699762e1c96826771f6c30b84579934d55d56 100644 (file)
 #ifndef X264_I386_PREDICT_H
 #define X264_I386_PREDICT_H
 
+#define x264_predict_16x16_init_mmx x264_template(predict_16x16_init_mmx)
 void x264_predict_16x16_init_mmx( int cpu, x264_predict_t pf[7] );
+#define x264_predict_8x16c_init_mmx x264_template(predict_8x16c_init_mmx)
 void x264_predict_8x16c_init_mmx( int cpu, x264_predict_t pf[7] );
+#define x264_predict_8x8c_init_mmx x264_template(predict_8x8c_init_mmx)
 void x264_predict_8x8c_init_mmx ( int cpu, x264_predict_t pf[7] );
+#define x264_predict_4x4_init_mmx x264_template(predict_4x4_init_mmx)
 void x264_predict_4x4_init_mmx  ( int cpu, x264_predict_t pf[12] );
+#define x264_predict_8x8_init_mmx x264_template(predict_8x8_init_mmx)
 void x264_predict_8x8_init_mmx  ( int cpu, x264_predict8x8_t pf[12], x264_predict_8x8_filter_t *predict_8x8_filter );
 
+#define x264_predict_16x16_v_mmx2 x264_template(predict_16x16_v_mmx2)
 void x264_predict_16x16_v_mmx2( pixel *src );
+#define x264_predict_16x16_v_sse x264_template(predict_16x16_v_sse)
 void x264_predict_16x16_v_sse ( pixel *src );
+#define x264_predict_16x16_v_avx x264_template(predict_16x16_v_avx)
 void x264_predict_16x16_v_avx ( uint16_t *src );
+#define x264_predict_16x16_h_mmx2 x264_template(predict_16x16_h_mmx2)
 void x264_predict_16x16_h_mmx2( pixel *src );
+#define x264_predict_16x16_h_sse2 x264_template(predict_16x16_h_sse2)
 void x264_predict_16x16_h_sse2( uint16_t *src );
+#define x264_predict_16x16_h_ssse3 x264_template(predict_16x16_h_ssse3)
 void x264_predict_16x16_h_ssse3( uint8_t *src );
+#define x264_predict_16x16_h_avx2 x264_template(predict_16x16_h_avx2)
 void x264_predict_16x16_h_avx2( uint16_t *src );
+#define x264_predict_16x16_dc_sse2 x264_template(predict_16x16_dc_sse2)
 void x264_predict_16x16_dc_sse2( pixel *src );
+#define x264_predict_16x16_dc_avx2 x264_template(predict_16x16_dc_avx2)
 void x264_predict_16x16_dc_avx2( pixel *src );
+#define x264_predict_16x16_dc_left_sse2 x264_template(predict_16x16_dc_left_sse2)
 void x264_predict_16x16_dc_left_sse2( pixel *src );
+#define x264_predict_16x16_dc_left_avx2 x264_template(predict_16x16_dc_left_avx2)
 void x264_predict_16x16_dc_left_avx2( pixel *src );
+#define x264_predict_16x16_dc_top_sse2 x264_template(predict_16x16_dc_top_sse2)
 void x264_predict_16x16_dc_top_sse2( pixel *src );
+#define x264_predict_16x16_dc_top_avx2 x264_template(predict_16x16_dc_top_avx2)
 void x264_predict_16x16_dc_top_avx2( pixel *src );
+#define x264_predict_16x16_p_core_mmx2 x264_template(predict_16x16_p_core_mmx2)
 void x264_predict_16x16_p_core_mmx2( uint8_t *src, int i00, int b, int c );
+#define x264_predict_16x16_p_core_sse2 x264_template(predict_16x16_p_core_sse2)
 void x264_predict_16x16_p_core_sse2( pixel *src, int i00, int b, int c );
+#define x264_predict_16x16_p_core_avx x264_template(predict_16x16_p_core_avx)
 void x264_predict_16x16_p_core_avx( pixel *src, int i00, int b, int c );
+#define x264_predict_16x16_p_core_avx2 x264_template(predict_16x16_p_core_avx2)
 void x264_predict_16x16_p_core_avx2( pixel *src, int i00, int b, int c );
+#define x264_predict_8x16c_dc_mmx2 x264_template(predict_8x16c_dc_mmx2)
 void x264_predict_8x16c_dc_mmx2( pixel *src );
+#define x264_predict_8x16c_dc_sse2 x264_template(predict_8x16c_dc_sse2)
 void x264_predict_8x16c_dc_sse2( uint16_t *src );
+#define x264_predict_8x16c_dc_top_mmx2 x264_template(predict_8x16c_dc_top_mmx2)
 void x264_predict_8x16c_dc_top_mmx2( uint8_t *src );
+#define x264_predict_8x16c_dc_top_sse2 x264_template(predict_8x16c_dc_top_sse2)
 void x264_predict_8x16c_dc_top_sse2( uint16_t *src );
+#define x264_predict_8x16c_v_mmx x264_template(predict_8x16c_v_mmx)
 void x264_predict_8x16c_v_mmx( uint8_t *src );
+#define x264_predict_8x16c_v_sse x264_template(predict_8x16c_v_sse)
 void x264_predict_8x16c_v_sse( uint16_t *src );
+#define x264_predict_8x16c_h_mmx2 x264_template(predict_8x16c_h_mmx2)
 void x264_predict_8x16c_h_mmx2( pixel *src );
+#define x264_predict_8x16c_h_sse2 x264_template(predict_8x16c_h_sse2)
 void x264_predict_8x16c_h_sse2( uint16_t *src );
+#define x264_predict_8x16c_h_ssse3 x264_template(predict_8x16c_h_ssse3)
 void x264_predict_8x16c_h_ssse3( uint8_t *src );
+#define x264_predict_8x16c_h_avx2 x264_template(predict_8x16c_h_avx2)
 void x264_predict_8x16c_h_avx2( uint16_t *src );
+#define x264_predict_8x16c_p_core_mmx2 x264_template(predict_8x16c_p_core_mmx2)
 void x264_predict_8x16c_p_core_mmx2( uint8_t *src, int i00, int b, int c );
+#define x264_predict_8x16c_p_core_sse2 x264_template(predict_8x16c_p_core_sse2)
 void x264_predict_8x16c_p_core_sse2( pixel *src, int i00, int b, int c );
+#define x264_predict_8x16c_p_core_avx x264_template(predict_8x16c_p_core_avx)
 void x264_predict_8x16c_p_core_avx ( pixel *src, int i00, int b, int c );
+#define x264_predict_8x16c_p_core_avx2 x264_template(predict_8x16c_p_core_avx2)
 void x264_predict_8x16c_p_core_avx2( pixel *src, int i00, int b, int c );
+#define x264_predict_8x8c_p_core_mmx2 x264_template(predict_8x8c_p_core_mmx2)
 void x264_predict_8x8c_p_core_mmx2( uint8_t *src, int i00, int b, int c );
+#define x264_predict_8x8c_p_core_sse2 x264_template(predict_8x8c_p_core_sse2)
 void x264_predict_8x8c_p_core_sse2( pixel *src, int i00, int b, int c );
+#define x264_predict_8x8c_p_core_avx x264_template(predict_8x8c_p_core_avx)
 void x264_predict_8x8c_p_core_avx ( pixel *src, int i00, int b, int c );
+#define x264_predict_8x8c_p_core_avx2 x264_template(predict_8x8c_p_core_avx2)
 void x264_predict_8x8c_p_core_avx2( pixel *src, int i00, int b, int c );
+#define x264_predict_8x8c_dc_mmx2 x264_template(predict_8x8c_dc_mmx2)
 void x264_predict_8x8c_dc_mmx2( pixel *src );
+#define x264_predict_8x8c_dc_sse2 x264_template(predict_8x8c_dc_sse2)
 void x264_predict_8x8c_dc_sse2( uint16_t *src );
+#define x264_predict_8x8c_dc_top_mmx2 x264_template(predict_8x8c_dc_top_mmx2)
 void x264_predict_8x8c_dc_top_mmx2( uint8_t *src );
+#define x264_predict_8x8c_dc_top_sse2 x264_template(predict_8x8c_dc_top_sse2)
 void x264_predict_8x8c_dc_top_sse2( uint16_t *src );
+#define x264_predict_8x8c_v_mmx x264_template(predict_8x8c_v_mmx)
 void x264_predict_8x8c_v_mmx( pixel *src );
+#define x264_predict_8x8c_v_sse x264_template(predict_8x8c_v_sse)
 void x264_predict_8x8c_v_sse( uint16_t *src );
+#define x264_predict_8x8c_h_mmx2 x264_template(predict_8x8c_h_mmx2)
 void x264_predict_8x8c_h_mmx2( pixel *src );
+#define x264_predict_8x8c_h_sse2 x264_template(predict_8x8c_h_sse2)
 void x264_predict_8x8c_h_sse2( uint16_t *src );
+#define x264_predict_8x8c_h_ssse3 x264_template(predict_8x8c_h_ssse3)
 void x264_predict_8x8c_h_ssse3( uint8_t *src );
+#define x264_predict_8x8c_h_avx2 x264_template(predict_8x8c_h_avx2)
 void x264_predict_8x8c_h_avx2( uint16_t *src );
+#define x264_predict_8x8_v_mmx2 x264_template(predict_8x8_v_mmx2)
 void x264_predict_8x8_v_mmx2( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_v_sse x264_template(predict_8x8_v_sse)
 void x264_predict_8x8_v_sse ( uint16_t *src, uint16_t edge[36] );
+#define x264_predict_8x8_h_mmx2 x264_template(predict_8x8_h_mmx2)
 void x264_predict_8x8_h_mmx2( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_h_sse2 x264_template(predict_8x8_h_sse2)
 void x264_predict_8x8_h_sse2( uint16_t *src, uint16_t edge[36] );
+#define x264_predict_8x8_hd_mmx2 x264_template(predict_8x8_hd_mmx2)
 void x264_predict_8x8_hd_mmx2( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_hu_mmx2 x264_template(predict_8x8_hu_mmx2)
 void x264_predict_8x8_hu_mmx2( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_dc_mmx2 x264_template(predict_8x8_dc_mmx2)
 void x264_predict_8x8_dc_mmx2( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_dc_sse2 x264_template(predict_8x8_dc_sse2)
 void x264_predict_8x8_dc_sse2( uint16_t *src, uint16_t edge[36] );
+#define x264_predict_8x8_dc_top_mmx2 x264_template(predict_8x8_dc_top_mmx2)
 void x264_predict_8x8_dc_top_mmx2( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_dc_top_sse2 x264_template(predict_8x8_dc_top_sse2)
 void x264_predict_8x8_dc_top_sse2( uint16_t *src, uint16_t edge[36] );
+#define x264_predict_8x8_dc_left_mmx2 x264_template(predict_8x8_dc_left_mmx2)
 void x264_predict_8x8_dc_left_mmx2( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_dc_left_sse2 x264_template(predict_8x8_dc_left_sse2)
 void x264_predict_8x8_dc_left_sse2( uint16_t *src, uint16_t edge[36] );
+#define x264_predict_8x8_ddl_mmx2 x264_template(predict_8x8_ddl_mmx2)
 void x264_predict_8x8_ddl_mmx2( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_ddl_sse2 x264_template(predict_8x8_ddl_sse2)
 void x264_predict_8x8_ddl_sse2( pixel *src, pixel edge[36] );
+#define x264_predict_8x8_ddl_ssse3 x264_template(predict_8x8_ddl_ssse3)
 void x264_predict_8x8_ddl_ssse3( pixel *src, pixel edge[36] );
+#define x264_predict_8x8_ddl_cache64_ssse3 x264_template(predict_8x8_ddl_cache64_ssse3)
 void x264_predict_8x8_ddl_cache64_ssse3( pixel *src, pixel edge[36] );
+#define x264_predict_8x8_ddl_avx x264_template(predict_8x8_ddl_avx)
 void x264_predict_8x8_ddl_avx( pixel *src, pixel edge[36] );
+#define x264_predict_8x8_ddr_mmx2 x264_template(predict_8x8_ddr_mmx2)
 void x264_predict_8x8_ddr_mmx2( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_ddr_sse2 x264_template(predict_8x8_ddr_sse2)
 void x264_predict_8x8_ddr_sse2( pixel *src, pixel edge[36] );
+#define x264_predict_8x8_ddr_ssse3 x264_template(predict_8x8_ddr_ssse3)
 void x264_predict_8x8_ddr_ssse3( pixel *src, pixel edge[36] );
+#define x264_predict_8x8_ddr_cache64_ssse3 x264_template(predict_8x8_ddr_cache64_ssse3)
 void x264_predict_8x8_ddr_cache64_ssse3( pixel *src, pixel edge[36] );
+#define x264_predict_8x8_ddr_avx x264_template(predict_8x8_ddr_avx)
 void x264_predict_8x8_ddr_avx( pixel *src, pixel edge[36] );
+#define x264_predict_8x8_vl_sse2 x264_template(predict_8x8_vl_sse2)
 void x264_predict_8x8_vl_sse2( pixel *src, pixel edge[36] );
+#define x264_predict_8x8_vl_ssse3 x264_template(predict_8x8_vl_ssse3)
 void x264_predict_8x8_vl_ssse3( pixel *src, pixel edge[36] );
+#define x264_predict_8x8_vl_avx x264_template(predict_8x8_vl_avx)
 void x264_predict_8x8_vl_avx( pixel *src, pixel edge[36] );
+#define x264_predict_8x8_vl_mmx2 x264_template(predict_8x8_vl_mmx2)
 void x264_predict_8x8_vl_mmx2( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_vr_mmx2 x264_template(predict_8x8_vr_mmx2)
 void x264_predict_8x8_vr_mmx2( uint8_t *src, uint8_t edge[36] );
+#define x264_predict_8x8_vr_sse2 x264_template(predict_8x8_vr_sse2)
 void x264_predict_8x8_vr_sse2( pixel *src, pixel edge[36] );
+#define x264_predict_8x8_vr_ssse3 x264_template(predict_8x8_vr_ssse3)
 void x264_predict_8x8_vr_ssse3( pixel *src, pixel edge[36] );
+#define x264_predict_8x8_vr_avx x264_template(predict_8x8_vr_avx)
 void x264_predict_8x8_vr_avx( pixel *src, pixel edge[36] );
+#define x264_predict_8x8_hu_sse2 x264_template(predict_8x8_hu_sse2)
 void x264_predict_8x8_hu_sse2( pixel *src, pixel edge[36] );
+#define x264_predict_8x8_hu_ssse3 x264_template(predict_8x8_hu_ssse3)
 void x264_predict_8x8_hu_ssse3( pixel *src, pixel edge[36] );
+#define x264_predict_8x8_hu_avx x264_template(predict_8x8_hu_avx)
 void x264_predict_8x8_hu_avx( pixel *src, pixel edge[36] );
+#define x264_predict_8x8_hd_sse2 x264_template(predict_8x8_hd_sse2)
 void x264_predict_8x8_hd_sse2( pixel *src, pixel edge[36] );
+#define x264_predict_8x8_hd_ssse3 x264_template(predict_8x8_hd_ssse3)
 void x264_predict_8x8_hd_ssse3( pixel *src, pixel edge[36] );
+#define x264_predict_8x8_hd_avx x264_template(predict_8x8_hd_avx)
 void x264_predict_8x8_hd_avx( pixel *src, pixel edge[36] );
+#define x264_predict_8x8_filter_mmx2 x264_template(predict_8x8_filter_mmx2)
 void x264_predict_8x8_filter_mmx2( uint8_t *src, uint8_t edge[36], int i_neighbor, int i_filters );
+#define x264_predict_8x8_filter_sse2 x264_template(predict_8x8_filter_sse2)
 void x264_predict_8x8_filter_sse2( uint16_t *src, uint16_t edge[36], int i_neighbor, int i_filters );
+#define x264_predict_8x8_filter_ssse3 x264_template(predict_8x8_filter_ssse3)
 void x264_predict_8x8_filter_ssse3( pixel *src, pixel edge[36], int i_neighbor, int i_filters );
+#define x264_predict_8x8_filter_avx x264_template(predict_8x8_filter_avx)
 void x264_predict_8x8_filter_avx( uint16_t *src, uint16_t edge[36], int i_neighbor, int i_filters );
+#define x264_predict_4x4_h_avx2 x264_template(predict_4x4_h_avx2)
 void x264_predict_4x4_h_avx2( uint16_t *src );
+#define x264_predict_4x4_ddl_mmx2 x264_template(predict_4x4_ddl_mmx2)
 void x264_predict_4x4_ddl_mmx2( pixel *src );
+#define x264_predict_4x4_ddl_sse2 x264_template(predict_4x4_ddl_sse2)
 void x264_predict_4x4_ddl_sse2( uint16_t *src );
+#define x264_predict_4x4_ddl_avx x264_template(predict_4x4_ddl_avx)
 void x264_predict_4x4_ddl_avx( uint16_t *src );
+#define x264_predict_4x4_ddr_mmx2 x264_template(predict_4x4_ddr_mmx2)
 void x264_predict_4x4_ddr_mmx2( pixel *src );
+#define x264_predict_4x4_vl_mmx2 x264_template(predict_4x4_vl_mmx2)
 void x264_predict_4x4_vl_mmx2( pixel *src );
+#define x264_predict_4x4_vl_sse2 x264_template(predict_4x4_vl_sse2)
 void x264_predict_4x4_vl_sse2( uint16_t *src );
+#define x264_predict_4x4_vl_avx x264_template(predict_4x4_vl_avx)
 void x264_predict_4x4_vl_avx( uint16_t *src );
+#define x264_predict_4x4_vr_mmx2 x264_template(predict_4x4_vr_mmx2)
 void x264_predict_4x4_vr_mmx2( uint8_t *src );
+#define x264_predict_4x4_vr_sse2 x264_template(predict_4x4_vr_sse2)
 void x264_predict_4x4_vr_sse2( uint16_t *src );
+#define x264_predict_4x4_vr_ssse3 x264_template(predict_4x4_vr_ssse3)
 void x264_predict_4x4_vr_ssse3( pixel *src );
+#define x264_predict_4x4_vr_cache64_ssse3 x264_template(predict_4x4_vr_cache64_ssse3)
 void x264_predict_4x4_vr_cache64_ssse3( uint8_t *src );
+#define x264_predict_4x4_vr_avx x264_template(predict_4x4_vr_avx)
 void x264_predict_4x4_vr_avx( uint16_t *src );
+#define x264_predict_4x4_hd_mmx2 x264_template(predict_4x4_hd_mmx2)
 void x264_predict_4x4_hd_mmx2( pixel *src );
+#define x264_predict_4x4_hd_sse2 x264_template(predict_4x4_hd_sse2)
 void x264_predict_4x4_hd_sse2( uint16_t *src );
+#define x264_predict_4x4_hd_ssse3 x264_template(predict_4x4_hd_ssse3)
 void x264_predict_4x4_hd_ssse3( pixel *src );
+#define x264_predict_4x4_hd_avx x264_template(predict_4x4_hd_avx)
 void x264_predict_4x4_hd_avx( uint16_t *src );
+#define x264_predict_4x4_dc_mmx2 x264_template(predict_4x4_dc_mmx2)
 void x264_predict_4x4_dc_mmx2( pixel *src );
+#define x264_predict_4x4_ddr_sse2 x264_template(predict_4x4_ddr_sse2)
 void x264_predict_4x4_ddr_sse2( uint16_t *src );
+#define x264_predict_4x4_ddr_ssse3 x264_template(predict_4x4_ddr_ssse3)
 void x264_predict_4x4_ddr_ssse3( pixel *src );
+#define x264_predict_4x4_ddr_avx x264_template(predict_4x4_ddr_avx)
 void x264_predict_4x4_ddr_avx( uint16_t *src );
+#define x264_predict_4x4_hu_mmx2 x264_template(predict_4x4_hu_mmx2)
 void x264_predict_4x4_hu_mmx2( pixel *src );
 
 #endif
index f8ebbe556ef9485cad026e6ac7f5c121cce15072..bdfe0b34f239e951d1e0887bf673ec44e737bf6d 100644 (file)
@@ -1421,8 +1421,8 @@ cglobal denoise_dct, 4,4,4
 %endif
 %endmacro
 
-cextern decimate_table4
-cextern decimate_table8
+cextern_common decimate_table4
+cextern_common decimate_table8
 
 %macro DECIMATE4x4 1
 
index 6b74aacef59fe10d31b9d96cffe6aaab0e96e878..a37f71712f25d28b6b2ea77a411cfda792fd3e38 100644 (file)
 #ifndef X264_I386_QUANT_H
 #define X264_I386_QUANT_H
 
+#define x264_quant_2x2_dc_mmx2 x264_template(quant_2x2_dc_mmx2)
 int x264_quant_2x2_dc_mmx2( dctcoef dct[4], int mf, int bias );
+#define x264_quant_4x4_dc_mmx2 x264_template(quant_4x4_dc_mmx2)
 int x264_quant_4x4_dc_mmx2( dctcoef dct[16], int mf, int bias );
+#define x264_quant_4x4_mmx2 x264_template(quant_4x4_mmx2)
 int x264_quant_4x4_mmx2( dctcoef dct[16], udctcoef mf[16], udctcoef bias[16] );
+#define x264_quant_8x8_mmx2 x264_template(quant_8x8_mmx2)
 int x264_quant_8x8_mmx2( dctcoef dct[64], udctcoef mf[64], udctcoef bias[64] );
+#define x264_quant_2x2_dc_sse2 x264_template(quant_2x2_dc_sse2)
 int x264_quant_2x2_dc_sse2( dctcoef dct[16], int mf, int bias );
+#define x264_quant_4x4_dc_sse2 x264_template(quant_4x4_dc_sse2)
 int x264_quant_4x4_dc_sse2( dctcoef dct[16], int mf, int bias );
+#define x264_quant_4x4_sse2 x264_template(quant_4x4_sse2)
 int x264_quant_4x4_sse2( dctcoef dct[16], udctcoef mf[16], udctcoef bias[16] );
+#define x264_quant_4x4x4_sse2 x264_template(quant_4x4x4_sse2)
 int x264_quant_4x4x4_sse2( dctcoef dct[4][16], udctcoef mf[16], udctcoef bias[16] );
+#define x264_quant_8x8_sse2 x264_template(quant_8x8_sse2)
 int x264_quant_8x8_sse2( dctcoef dct[64], udctcoef mf[64], udctcoef bias[64] );
+#define x264_quant_2x2_dc_ssse3 x264_template(quant_2x2_dc_ssse3)
 int x264_quant_2x2_dc_ssse3( dctcoef dct[4], int mf, int bias );
+#define x264_quant_4x4_dc_ssse3 x264_template(quant_4x4_dc_ssse3)
 int x264_quant_4x4_dc_ssse3( dctcoef dct[16], int mf, int bias );
+#define x264_quant_4x4_ssse3 x264_template(quant_4x4_ssse3)
 int x264_quant_4x4_ssse3( dctcoef dct[16], udctcoef mf[16], udctcoef bias[16] );
+#define x264_quant_4x4x4_ssse3 x264_template(quant_4x4x4_ssse3)
 int x264_quant_4x4x4_ssse3( dctcoef dct[4][16], udctcoef mf[16], udctcoef bias[16] );
+#define x264_quant_8x8_ssse3 x264_template(quant_8x8_ssse3)
 int x264_quant_8x8_ssse3( dctcoef dct[64], udctcoef mf[64], udctcoef bias[64] );
+#define x264_quant_2x2_dc_sse4 x264_template(quant_2x2_dc_sse4)
 int x264_quant_2x2_dc_sse4( dctcoef dct[16], int mf, int bias );
+#define x264_quant_4x4_dc_sse4 x264_template(quant_4x4_dc_sse4)
 int x264_quant_4x4_dc_sse4( dctcoef dct[16], int mf, int bias );
+#define x264_quant_4x4_sse4 x264_template(quant_4x4_sse4)
 int x264_quant_4x4_sse4( dctcoef dct[16], udctcoef mf[16], udctcoef bias[16] );
+#define x264_quant_4x4x4_sse4 x264_template(quant_4x4x4_sse4)
 int x264_quant_4x4x4_sse4( dctcoef dct[4][16], udctcoef mf[16], udctcoef bias[16] );
+#define x264_quant_8x8_sse4 x264_template(quant_8x8_sse4)
 int x264_quant_8x8_sse4( dctcoef dct[64], udctcoef mf[64], udctcoef bias[64] );
+#define x264_quant_4x4_avx2 x264_template(quant_4x4_avx2)
 int x264_quant_4x4_avx2( dctcoef dct[16], udctcoef mf[16], udctcoef bias[16] );
+#define x264_quant_4x4_dc_avx2 x264_template(quant_4x4_dc_avx2)
 int x264_quant_4x4_dc_avx2( dctcoef dct[16], int mf, int bias );
+#define x264_quant_8x8_avx2 x264_template(quant_8x8_avx2)
 int x264_quant_8x8_avx2( dctcoef dct[64], udctcoef mf[64], udctcoef bias[64] );
+#define x264_quant_4x4x4_avx2 x264_template(quant_4x4x4_avx2)
 int x264_quant_4x4x4_avx2( dctcoef dct[4][16], udctcoef mf[16], udctcoef bias[16] );
+#define x264_dequant_4x4_mmx x264_template(dequant_4x4_mmx)
 void x264_dequant_4x4_mmx( int16_t dct[16], int dequant_mf[6][16], int i_qp );
+#define x264_dequant_4x4dc_mmx2 x264_template(dequant_4x4dc_mmx2)
 void x264_dequant_4x4dc_mmx2( int16_t dct[16], int dequant_mf[6][16], int i_qp );
+#define x264_dequant_8x8_mmx x264_template(dequant_8x8_mmx)
 void x264_dequant_8x8_mmx( int16_t dct[64], int dequant_mf[6][64], int i_qp );
+#define x264_dequant_4x4_sse2 x264_template(dequant_4x4_sse2)
 void x264_dequant_4x4_sse2( dctcoef dct[16], int dequant_mf[6][16], int i_qp );
+#define x264_dequant_4x4dc_sse2 x264_template(dequant_4x4dc_sse2)
 void x264_dequant_4x4dc_sse2( dctcoef dct[16], int dequant_mf[6][16], int i_qp );
+#define x264_dequant_8x8_sse2 x264_template(dequant_8x8_sse2)
 void x264_dequant_8x8_sse2( dctcoef dct[64], int dequant_mf[6][64], int i_qp );
+#define x264_dequant_4x4_avx x264_template(dequant_4x4_avx)
 void x264_dequant_4x4_avx( dctcoef dct[16], int dequant_mf[6][16], int i_qp );
+#define x264_dequant_4x4dc_avx x264_template(dequant_4x4dc_avx)
 void x264_dequant_4x4dc_avx( dctcoef dct[16], int dequant_mf[6][16], int i_qp );
+#define x264_dequant_8x8_avx x264_template(dequant_8x8_avx)
 void x264_dequant_8x8_avx( dctcoef dct[64], int dequant_mf[6][64], int i_qp );
+#define x264_dequant_4x4_xop x264_template(dequant_4x4_xop)
 void x264_dequant_4x4_xop( dctcoef dct[16], int dequant_mf[6][16], int i_qp );
+#define x264_dequant_4x4dc_xop x264_template(dequant_4x4dc_xop)
 void x264_dequant_4x4dc_xop( dctcoef dct[16], int dequant_mf[6][16], int i_qp );
+#define x264_dequant_8x8_xop x264_template(dequant_8x8_xop)
 void x264_dequant_8x8_xop( dctcoef dct[64], int dequant_mf[6][64], int i_qp );
+#define x264_dequant_4x4_avx2 x264_template(dequant_4x4_avx2)
 void x264_dequant_4x4_avx2( dctcoef dct[16], int dequant_mf[6][16], int i_qp );
+#define x264_dequant_4x4dc_avx2 x264_template(dequant_4x4dc_avx2)
 void x264_dequant_4x4dc_avx2( dctcoef dct[16], int dequant_mf[6][16], int i_qp );
+#define x264_dequant_8x8_avx2 x264_template(dequant_8x8_avx2)
 void x264_dequant_8x8_avx2( dctcoef dct[64], int dequant_mf[6][64], int i_qp );
+#define x264_dequant_4x4_avx512 x264_template(dequant_4x4_avx512)
 void x264_dequant_4x4_avx512( dctcoef dct[16], int dequant_mf[6][16], int i_qp );
+#define x264_dequant_8x8_avx512 x264_template(dequant_8x8_avx512)
 void x264_dequant_8x8_avx512( dctcoef dct[64], int dequant_mf[6][64], int i_qp );
+#define x264_dequant_4x4_flat16_mmx x264_template(dequant_4x4_flat16_mmx)
 void x264_dequant_4x4_flat16_mmx( int16_t dct[16], int dequant_mf[6][16], int i_qp );
+#define x264_dequant_8x8_flat16_mmx x264_template(dequant_8x8_flat16_mmx)
 void x264_dequant_8x8_flat16_mmx( int16_t dct[64], int dequant_mf[6][64], int i_qp );
+#define x264_dequant_4x4_flat16_sse2 x264_template(dequant_4x4_flat16_sse2)
 void x264_dequant_4x4_flat16_sse2( int16_t dct[16], int dequant_mf[6][16], int i_qp );
+#define x264_dequant_8x8_flat16_sse2 x264_template(dequant_8x8_flat16_sse2)
 void x264_dequant_8x8_flat16_sse2( int16_t dct[64], int dequant_mf[6][64], int i_qp );
+#define x264_dequant_4x4_flat16_avx2 x264_template(dequant_4x4_flat16_avx2)
 void x264_dequant_4x4_flat16_avx2( int16_t dct[16], int dequant_mf[6][16], int i_qp );
+#define x264_dequant_8x8_flat16_avx2 x264_template(dequant_8x8_flat16_avx2)
 void x264_dequant_8x8_flat16_avx2( int16_t dct[64], int dequant_mf[6][64], int i_qp );
+#define x264_dequant_8x8_flat16_avx512 x264_template(dequant_8x8_flat16_avx512)
 void x264_dequant_8x8_flat16_avx512( int16_t dct[64], int dequant_mf[6][64], int i_qp );
+#define x264_idct_dequant_2x4_dc_sse2 x264_template(idct_dequant_2x4_dc_sse2)
 void x264_idct_dequant_2x4_dc_sse2( dctcoef dct[8], dctcoef dct4x4[8][16], int dequant_mf[6][16], int i_qp );
+#define x264_idct_dequant_2x4_dc_avx x264_template(idct_dequant_2x4_dc_avx)
 void x264_idct_dequant_2x4_dc_avx ( dctcoef dct[8], dctcoef dct4x4[8][16], int dequant_mf[6][16], int i_qp );
+#define x264_idct_dequant_2x4_dconly_sse2 x264_template(idct_dequant_2x4_dconly_sse2)
 void x264_idct_dequant_2x4_dconly_sse2( dctcoef dct[8], int dequant_mf[6][16], int i_qp );
+#define x264_idct_dequant_2x4_dconly_avx x264_template(idct_dequant_2x4_dconly_avx)
 void x264_idct_dequant_2x4_dconly_avx ( dctcoef dct[8], int dequant_mf[6][16], int i_qp );
+#define x264_optimize_chroma_2x2_dc_sse2 x264_template(optimize_chroma_2x2_dc_sse2)
 int x264_optimize_chroma_2x2_dc_sse2( dctcoef dct[4], int dequant_mf );
+#define x264_optimize_chroma_2x2_dc_ssse3 x264_template(optimize_chroma_2x2_dc_ssse3)
 int x264_optimize_chroma_2x2_dc_ssse3( dctcoef dct[4], int dequant_mf );
+#define x264_optimize_chroma_2x2_dc_sse4 x264_template(optimize_chroma_2x2_dc_sse4)
 int x264_optimize_chroma_2x2_dc_sse4( dctcoef dct[4], int dequant_mf );
+#define x264_optimize_chroma_2x2_dc_avx x264_template(optimize_chroma_2x2_dc_avx)
 int x264_optimize_chroma_2x2_dc_avx( dctcoef dct[4], int dequant_mf );
+#define x264_denoise_dct_mmx x264_template(denoise_dct_mmx)
 void x264_denoise_dct_mmx  ( dctcoef *dct, uint32_t *sum, udctcoef *offset, int size );
+#define x264_denoise_dct_sse2 x264_template(denoise_dct_sse2)
 void x264_denoise_dct_sse2 ( dctcoef *dct, uint32_t *sum, udctcoef *offset, int size );
+#define x264_denoise_dct_ssse3 x264_template(denoise_dct_ssse3)
 void x264_denoise_dct_ssse3( dctcoef *dct, uint32_t *sum, udctcoef *offset, int size );
+#define x264_denoise_dct_avx x264_template(denoise_dct_avx)
 void x264_denoise_dct_avx  ( dctcoef *dct, uint32_t *sum, udctcoef *offset, int size );
+#define x264_denoise_dct_avx2 x264_template(denoise_dct_avx2)
 void x264_denoise_dct_avx2 ( dctcoef *dct, uint32_t *sum, udctcoef *offset, int size );
+#define x264_decimate_score15_sse2 x264_template(decimate_score15_sse2)
 int x264_decimate_score15_sse2( dctcoef *dct );
+#define x264_decimate_score15_ssse3 x264_template(decimate_score15_ssse3)
 int x264_decimate_score15_ssse3( dctcoef *dct );
+#define x264_decimate_score15_avx512 x264_template(decimate_score15_avx512)
 int x264_decimate_score15_avx512( dctcoef *dct );
+#define x264_decimate_score16_sse2 x264_template(decimate_score16_sse2)
 int x264_decimate_score16_sse2( dctcoef *dct );
+#define x264_decimate_score16_ssse3 x264_template(decimate_score16_ssse3)
 int x264_decimate_score16_ssse3( dctcoef *dct );
+#define x264_decimate_score16_avx512 x264_template(decimate_score16_avx512)
 int x264_decimate_score16_avx512( dctcoef *dct );
+#define x264_decimate_score64_sse2 x264_template(decimate_score64_sse2)
 int x264_decimate_score64_sse2( dctcoef *dct );
+#define x264_decimate_score64_ssse3 x264_template(decimate_score64_ssse3)
 int x264_decimate_score64_ssse3( dctcoef *dct );
+#define x264_decimate_score64_avx2 x264_template(decimate_score64_avx2)
 int x264_decimate_score64_avx2( int16_t *dct );
+#define x264_decimate_score64_avx512 x264_template(decimate_score64_avx512)
 int x264_decimate_score64_avx512( dctcoef *dct );
+#define x264_coeff_last4_mmx2 x264_template(coeff_last4_mmx2)
 int x264_coeff_last4_mmx2( dctcoef *dct );
+#define x264_coeff_last8_mmx2 x264_template(coeff_last8_mmx2)
 int x264_coeff_last8_mmx2( dctcoef *dct );
+#define x264_coeff_last15_mmx2 x264_template(coeff_last15_mmx2)
 int x264_coeff_last15_mmx2( dctcoef *dct );
+#define x264_coeff_last16_mmx2 x264_template(coeff_last16_mmx2)
 int x264_coeff_last16_mmx2( dctcoef *dct );
+#define x264_coeff_last64_mmx2 x264_template(coeff_last64_mmx2)
 int x264_coeff_last64_mmx2( dctcoef *dct );
+#define x264_coeff_last8_sse2 x264_template(coeff_last8_sse2)
 int x264_coeff_last8_sse2( dctcoef *dct );
+#define x264_coeff_last15_sse2 x264_template(coeff_last15_sse2)
 int x264_coeff_last15_sse2( dctcoef *dct );
+#define x264_coeff_last16_sse2 x264_template(coeff_last16_sse2)
 int x264_coeff_last16_sse2( dctcoef *dct );
+#define x264_coeff_last64_sse2 x264_template(coeff_last64_sse2)
 int x264_coeff_last64_sse2( dctcoef *dct );
+#define x264_coeff_last4_lzcnt x264_template(coeff_last4_lzcnt)
 int x264_coeff_last4_lzcnt( dctcoef *dct );
+#define x264_coeff_last8_lzcnt x264_template(coeff_last8_lzcnt)
 int x264_coeff_last8_lzcnt( dctcoef *dct );
+#define x264_coeff_last15_lzcnt x264_template(coeff_last15_lzcnt)
 int x264_coeff_last15_lzcnt( dctcoef *dct );
+#define x264_coeff_last16_lzcnt x264_template(coeff_last16_lzcnt)
 int x264_coeff_last16_lzcnt( dctcoef *dct );
+#define x264_coeff_last64_lzcnt x264_template(coeff_last64_lzcnt)
 int x264_coeff_last64_lzcnt( dctcoef *dct );
+#define x264_coeff_last64_avx2 x264_template(coeff_last64_avx2)
 int x264_coeff_last64_avx2 ( dctcoef *dct );
+#define x264_coeff_last4_avx512 x264_template(coeff_last4_avx512)
 int x264_coeff_last4_avx512( int32_t *dct );
+#define x264_coeff_last8_avx512 x264_template(coeff_last8_avx512)
 int x264_coeff_last8_avx512( dctcoef *dct );
+#define x264_coeff_last15_avx512 x264_template(coeff_last15_avx512)
 int x264_coeff_last15_avx512( dctcoef *dct );
+#define x264_coeff_last16_avx512 x264_template(coeff_last16_avx512)
 int x264_coeff_last16_avx512( dctcoef *dct );
+#define x264_coeff_last64_avx512 x264_template(coeff_last64_avx512)
 int x264_coeff_last64_avx512( dctcoef *dct );
+#define x264_coeff_level_run16_mmx2 x264_template(coeff_level_run16_mmx2)
 int x264_coeff_level_run16_mmx2( dctcoef *dct, x264_run_level_t *runlevel );
+#define x264_coeff_level_run16_sse2 x264_template(coeff_level_run16_sse2)
 int x264_coeff_level_run16_sse2( dctcoef *dct, x264_run_level_t *runlevel );
+#define x264_coeff_level_run16_lzcnt x264_template(coeff_level_run16_lzcnt)
 int x264_coeff_level_run16_lzcnt( dctcoef *dct, x264_run_level_t *runlevel );
+#define x264_coeff_level_run16_ssse3 x264_template(coeff_level_run16_ssse3)
 int x264_coeff_level_run16_ssse3( dctcoef *dct, x264_run_level_t *runlevel );
+#define x264_coeff_level_run16_ssse3_lzcnt x264_template(coeff_level_run16_ssse3_lzcnt)
 int x264_coeff_level_run16_ssse3_lzcnt( dctcoef *dct, x264_run_level_t *runlevel );
+#define x264_coeff_level_run16_avx2 x264_template(coeff_level_run16_avx2)
 int x264_coeff_level_run16_avx2( dctcoef *dct, x264_run_level_t *runlevel );
+#define x264_coeff_level_run15_mmx2 x264_template(coeff_level_run15_mmx2)
 int x264_coeff_level_run15_mmx2( dctcoef *dct, x264_run_level_t *runlevel );
+#define x264_coeff_level_run15_sse2 x264_template(coeff_level_run15_sse2)
 int x264_coeff_level_run15_sse2( dctcoef *dct, x264_run_level_t *runlevel );
+#define x264_coeff_level_run15_lzcnt x264_template(coeff_level_run15_lzcnt)
 int x264_coeff_level_run15_lzcnt( dctcoef *dct, x264_run_level_t *runlevel );
+#define x264_coeff_level_run15_ssse3 x264_template(coeff_level_run15_ssse3)
 int x264_coeff_level_run15_ssse3( dctcoef *dct, x264_run_level_t *runlevel );
+#define x264_coeff_level_run15_ssse3_lzcnt x264_template(coeff_level_run15_ssse3_lzcnt)
 int x264_coeff_level_run15_ssse3_lzcnt( dctcoef *dct, x264_run_level_t *runlevel );
+#define x264_coeff_level_run15_avx2 x264_template(coeff_level_run15_avx2)
 int x264_coeff_level_run15_avx2( dctcoef *dct, x264_run_level_t *runlevel );
+#define x264_coeff_level_run4_mmx2 x264_template(coeff_level_run4_mmx2)
 int x264_coeff_level_run4_mmx2( dctcoef *dct, x264_run_level_t *runlevel );
+#define x264_coeff_level_run4_lzcnt x264_template(coeff_level_run4_lzcnt)
 int x264_coeff_level_run4_lzcnt( dctcoef *dct, x264_run_level_t *runlevel );
+#define x264_coeff_level_run4_ssse3 x264_template(coeff_level_run4_ssse3)
 int x264_coeff_level_run4_ssse3( dctcoef *dct, x264_run_level_t *runlevel );
+#define x264_coeff_level_run4_ssse3_lzcnt x264_template(coeff_level_run4_ssse3_lzcnt)
 int x264_coeff_level_run4_ssse3_lzcnt( dctcoef *dct, x264_run_level_t *runlevel );
+#define x264_coeff_level_run8_mmx2 x264_template(coeff_level_run8_mmx2)
 int x264_coeff_level_run8_mmx2( dctcoef *dct, x264_run_level_t *runlevel );
+#define x264_coeff_level_run8_lzcnt x264_template(coeff_level_run8_lzcnt)
 int x264_coeff_level_run8_lzcnt( dctcoef *dct, x264_run_level_t *runlevel );
+#define x264_coeff_level_run8_sse2 x264_template(coeff_level_run8_sse2)
 int x264_coeff_level_run8_sse2( dctcoef *dct, x264_run_level_t *runlevel );
-int x264_coeff_level_run8_lzcnt( dctcoef *dct, x264_run_level_t *runlevel );
+#define x264_coeff_level_run8_ssse3 x264_template(coeff_level_run8_ssse3)
 int x264_coeff_level_run8_ssse3( dctcoef *dct, x264_run_level_t *runlevel );
+#define x264_coeff_level_run8_ssse3_lzcnt x264_template(coeff_level_run8_ssse3_lzcnt)
 int x264_coeff_level_run8_ssse3_lzcnt( dctcoef *dct, x264_run_level_t *runlevel );
+#define x264_trellis_cabac_4x4_sse2 x264_template(trellis_cabac_4x4_sse2)
 int x264_trellis_cabac_4x4_sse2 ( TRELLIS_PARAMS, int b_ac );
+#define x264_trellis_cabac_4x4_ssse3 x264_template(trellis_cabac_4x4_ssse3)
 int x264_trellis_cabac_4x4_ssse3( TRELLIS_PARAMS, int b_ac );
+#define x264_trellis_cabac_8x8_sse2 x264_template(trellis_cabac_8x8_sse2)
 int x264_trellis_cabac_8x8_sse2 ( TRELLIS_PARAMS, int b_interlaced );
+#define x264_trellis_cabac_8x8_ssse3 x264_template(trellis_cabac_8x8_ssse3)
 int x264_trellis_cabac_8x8_ssse3( TRELLIS_PARAMS, int b_interlaced );
+#define x264_trellis_cabac_4x4_psy_sse2 x264_template(trellis_cabac_4x4_psy_sse2)
 int x264_trellis_cabac_4x4_psy_sse2 ( TRELLIS_PARAMS, int b_ac, dctcoef *fenc_dct, int i_psy_trellis );
+#define x264_trellis_cabac_4x4_psy_ssse3 x264_template(trellis_cabac_4x4_psy_ssse3)
 int x264_trellis_cabac_4x4_psy_ssse3( TRELLIS_PARAMS, int b_ac, dctcoef *fenc_dct, int i_psy_trellis );
+#define x264_trellis_cabac_8x8_psy_sse2 x264_template(trellis_cabac_8x8_psy_sse2)
 int x264_trellis_cabac_8x8_psy_sse2 ( TRELLIS_PARAMS, int b_interlaced, dctcoef *fenc_dct, int i_psy_trellis );
+#define x264_trellis_cabac_8x8_psy_ssse3 x264_template(trellis_cabac_8x8_psy_ssse3)
 int x264_trellis_cabac_8x8_psy_ssse3( TRELLIS_PARAMS, int b_interlaced, dctcoef *fenc_dct, int i_psy_trellis );
+#define x264_trellis_cabac_dc_sse2 x264_template(trellis_cabac_dc_sse2)
 int x264_trellis_cabac_dc_sse2 ( TRELLIS_PARAMS, int i_coefs );
+#define x264_trellis_cabac_dc_ssse3 x264_template(trellis_cabac_dc_ssse3)
 int x264_trellis_cabac_dc_ssse3( TRELLIS_PARAMS, int i_coefs );
+#define x264_trellis_cabac_chroma_422_dc_sse2 x264_template(trellis_cabac_chroma_422_dc_sse2)
 int x264_trellis_cabac_chroma_422_dc_sse2 ( TRELLIS_PARAMS );
+#define x264_trellis_cabac_chroma_422_dc_ssse3 x264_template(trellis_cabac_chroma_422_dc_ssse3)
 int x264_trellis_cabac_chroma_422_dc_ssse3( TRELLIS_PARAMS );
 
 #endif
index 6317b7dca692223ff295dd1fee65c382ca942bf9..c9358410de8745d499ab5cc72ac380ec11c9f966 100644 (file)
@@ -61,17 +61,17 @@ pq_ffffffff: times 2 dq 0xffffffff
 cextern pd_8
 cextern pd_0123
 cextern pd_4567
-cextern cabac_entropy
-cextern cabac_transition
+cextern_common cabac_entropy
+cextern_common cabac_transition
 cextern cabac_size_unary
 cextern cabac_transition_unary
-cextern dct4_weight_tab
-cextern dct8_weight_tab
-cextern dct4_weight2_tab
-cextern dct8_weight2_tab
-cextern last_coeff_flag_offset_8x8
-cextern significant_coeff_flag_offset_8x8
-cextern coeff_flag_offset_chroma_422_dc
+cextern_common dct4_weight_tab
+cextern_common dct8_weight_tab
+cextern_common dct4_weight2_tab
+cextern_common dct8_weight2_tab
+cextern_common last_coeff_flag_offset_8x8
+cextern_common significant_coeff_flag_offset_8x8
+cextern_common coeff_flag_offset_chroma_422_dc
 
 SECTION .text
 
index 7a140ebd93ccd845b61bfbe1e7e379b09d41d293..24274fb639048bc8a634c55b511be5b1244c7297 100644 (file)
 ;* For more information, contact us at licensing@x264.com.
 ;*****************************************************************************
 
+; like cextern, but with a plain x264 prefix instead of a bitdepth-specific one
+%macro cextern_common 1
+    %xdefine %1 mangle(x264 %+ _ %+ %1)
+    CAT_XDEFINE cglobaled_, %1, 1
+    extern %1
+%endmacro
+
+%ifndef BIT_DEPTH
+    %assign BIT_DEPTH 0
+%endif
+
+%if BIT_DEPTH > 8
+    %assign HIGH_BIT_DEPTH 1
+%else
+    %assign HIGH_BIT_DEPTH 0
+%endif
+
 %assign FENC_STRIDE 16
 %assign FDEC_STRIDE 32
 
@@ -54,7 +71,6 @@
 %endif
 %endmacro
 
-
 %macro SBUTTERFLY 4
 %ifidn %1, dqqq
     vperm2i128  m%4, m%2, m%3, q0301 ; punpckh
index da4d1abc89fb805eafb10d791e71e48226a60d02..770f0d7092829d79381fb1c8fd7695bf3e8210bd 100755 (executable)
--- a/configure
+++ b/configure
@@ -30,7 +30,7 @@ Configuration options:
   --disable-thread         disable multithreaded encoding
   --disable-win32thread    disable win32threads (windows only)
   --disable-interlaced     disable interlaced encoding support
-  --bit-depth=BIT_DEPTH    set output bit depth (8-10) [8]
+  --bit-depth=BIT_DEPTH    set output bit depth (8, 10, all) [all]
   --chroma-format=FORMAT   output chroma format (420, 422, 444, all) [all]
 
 Advanced options:
@@ -276,6 +276,7 @@ configure_system_override() {
         fi
         arg="$(grep '#define X264_BIT_DEPTH ' $x264_config_path | sed -e 's/#define X264_BIT_DEPTH *//; s/ *$//')"
         if [ -n "$arg" ]; then
+            [ "$arg" = 0 ] && arg="all"
             if [ "$arg" != "$bit_depth" ]; then
                 echo "Override output bit depth with system libx264 configuration"
                 bit_depth="$arg"
@@ -353,7 +354,7 @@ debug="no"
 gprof="no"
 strip="no"
 pic="no"
-bit_depth="8"
+bit_depth="all"
 chroma_format="all"
 compiler="GNU"
 compiler_style="GNU"
@@ -377,7 +378,7 @@ NL="
 # list of all preprocessor HAVE values we can define
 CONFIG_HAVE="MALLOC_H ALTIVEC ALTIVEC_H MMX ARMV6 ARMV6T2 NEON BEOSTHREAD POSIXTHREAD WIN32THREAD THREAD LOG2F SWSCALE \
              LAVF FFMS GPAC AVS GPL VECTOREXT INTERLACED CPU_COUNT OPENCL THP LSMASH X86_INLINE_ASM AS_FUNC INTEL_DISPATCHER \
-             MSA MMAP WINRT VSX ARM_INLINE_ASM STRTOK_R"
+             MSA MMAP WINRT VSX ARM_INLINE_ASM STRTOK_R BITDEPTH8 BITDEPTH10"
 
 # parse options
 
@@ -491,11 +492,10 @@ for opt do
             ;;
         --bit-depth=*)
             bit_depth="$optarg"
-            if [ "$bit_depth" -lt "8" -o "$bit_depth" -gt "10" ]; then
-                echo "Supplied bit depth must be in range [8,10]."
+            if [ "$bit_depth" != "8" -a "$bit_depth" != "10" -a "$bit_depth" != "all" ]; then
+                echo "Supplied bit depth must be 8, 10 or all."
                 exit 1
             fi
-            bit_depth=`expr $bit_depth + 0`
             ;;
         --chroma-format=*)
             chroma_format="$optarg"
@@ -1276,20 +1276,20 @@ if [ $compiler = ICC -o $compiler = ICL ] ; then
     fi
 fi
 
-if [ "$bit_depth" -gt "8" ]; then
-    define HIGH_BIT_DEPTH
-    ASFLAGS="$ASFLAGS -DHIGH_BIT_DEPTH=1"
+if [ "$bit_depth" = "all" ]; then
+    define HAVE_BITDEPTH8
+    define HAVE_BITDEPTH10
+elif [ "$bit_depth" -eq "8" ]; then
+    define HAVE_BITDEPTH8
+elif [ "$bit_depth" -eq "10" ]; then
+    define HAVE_BITDEPTH10
     opencl="no"
-else
-    ASFLAGS="$ASFLAGS -DHIGH_BIT_DEPTH=0"
 fi
 
 if [ "$chroma_format" != "all" ]; then
     define CHROMA_FORMAT CHROMA_$chroma_format
 fi
 
-ASFLAGS="$ASFLAGS -DBIT_DEPTH=$bit_depth"
-
 [ $gpl = yes ] && define HAVE_GPL && x264_gpl=1 || x264_gpl=0
 
 [ $interlaced = yes ] && define HAVE_INTERLACED && x264_interlaced=1 || x264_interlaced=0
@@ -1300,10 +1300,10 @@ if [ "$opencl" = "yes" ]; then
     # cygwin can use opencl if it can use LoadLibrary
     if [ $SYS = WINDOWS ] || ([ $SYS = CYGWIN ] && cc_check windows.h "" "LoadLibraryW(0);") ; then
         opencl="yes"
-        define HAVE_OPENCL
+        define HAVE_OPENCL "(BIT_DEPTH==8)"
     elif [ "$SYS" = "LINUX" -o "$SYS" = "MACOSX" ] ; then
         opencl="yes"
-        define HAVE_OPENCL
+        define HAVE_OPENCL "(BIT_DEPTH==8)"
         libdl="-ldl"
     fi
     LDFLAGS="$LDFLAGS $libdl"
@@ -1311,17 +1311,17 @@ fi
 
 #define undefined vars as 0
 for var in $CONFIG_HAVE; do
-    grep -q "HAVE_$var 1" config.h || define HAVE_$var 0
+    grep -q "HAVE_$var " config.h || define HAVE_$var 0
 done
 
 # generate exported config file
 
-config_chroma_format="X264_CSP_I$chroma_format"
-[ "$config_chroma_format" == "X264_CSP_Iall" ] && config_chroma_format="0"
+[ "$bit_depth" = "all" ] && config_bit_depth="0" || config_bit_depth="$bit_depth"
+[ "$chroma_format" = "all" ] && config_chroma_format="0" || config_chroma_format="X264_CSP_I$chroma_format"
 cat > x264_config.h << EOF
-#define X264_BIT_DEPTH     $bit_depth
 #define X264_GPL           $x264_gpl
 #define X264_INTERLACED    $x264_interlaced
+#define X264_BIT_DEPTH     $config_bit_depth
 #define X264_CHROMA_FORMAT $config_chroma_format
 EOF
 
@@ -1436,8 +1436,9 @@ HAVE_OPENCL=$opencl
 EOF
 
 if [ $compiler_style = MS ]; then
-    echo '%.o: %.c' >> config.mak
-    echo '     $(CC) $(CFLAGS) -c -Fo$@ $<' >> config.mak
+    echo 'CC_O=-Fo$@' >> config.mak
+else
+    echo 'CC_O=-o $@' >> config.mak
 fi
 
 if [ "$cli" = "yes" ]; then
index 45c9767e6f1eedcf864aba9dac0987531e40d967..b8b29d9b8f3e7493b8f4ee0894d38f7db8017813 100644 (file)
@@ -120,124 +120,6 @@ typedef struct
 
 } x264_mb_analysis_t;
 
-/* lambda = pow(2,qp/6-2) */
-const uint16_t x264_lambda_tab[QP_MAX_MAX+1] =
-{
-   1,   1,   1,   1,   1,   1,   1,   1, /*  0- 7 */
-   1,   1,   1,   1,   1,   1,   1,   1, /*  8-15 */
-   2,   2,   2,   2,   3,   3,   3,   4, /* 16-23 */
-   4,   4,   5,   6,   6,   7,   8,   9, /* 24-31 */
-  10,  11,  13,  14,  16,  18,  20,  23, /* 32-39 */
-  25,  29,  32,  36,  40,  45,  51,  57, /* 40-47 */
-  64,  72,  81,  91, 102, 114, 128, 144, /* 48-55 */
- 161, 181, 203, 228, 256, 287, 323, 362, /* 56-63 */
- 406, 456, 512, 575, 645, 724, 813, 912, /* 64-71 */
-1024,1149,1290,1448,1625,1825,2048,2299, /* 72-79 */
-2580,2896,                               /* 80-81 */
-};
-
-/* lambda2 = pow(lambda,2) * .9 * 256 */
-/* Capped to avoid overflow */
-const int x264_lambda2_tab[QP_MAX_MAX+1] =
-{
-       14,       18,       22,       28,       36,       45,      57,      72, /*  0- 7 */
-       91,      115,      145,      182,      230,      290,     365,     460, /*  8-15 */
-      580,      731,      921,     1161,     1462,     1843,    2322,    2925, /* 16-23 */
-     3686,     4644,     5851,     7372,     9289,    11703,   14745,   18578, /* 24-31 */
-    23407,    29491,    37156,    46814,    58982,    74313,   93628,  117964, /* 32-39 */
-   148626,   187257,   235929,   297252,   374514,   471859,  594505,  749029, /* 40-47 */
-   943718,  1189010,  1498059,  1887436,  2378021,  2996119, 3774873, 4756042, /* 48-55 */
-  5992238,  7549747,  9512085, 11984476, 15099494, 19024170,23968953,30198988, /* 56-63 */
- 38048341, 47937906, 60397977, 76096683, 95875813,120795955,                   /* 64-69 */
-134217727,134217727,134217727,134217727,134217727,134217727,                   /* 70-75 */
-134217727,134217727,134217727,134217727,134217727,134217727,                   /* 76-81 */
-};
-
-const uint8_t x264_exp2_lut[64] =
-{
-      0,   3,   6,   8,  11,  14,  17,  20,  23,  26,  29,  32,  36,  39,  42,  45,
-     48,  52,  55,  58,  62,  65,  69,  72,  76,  80,  83,  87,  91,  94,  98, 102,
-    106, 110, 114, 118, 122, 126, 130, 135, 139, 143, 147, 152, 156, 161, 165, 170,
-    175, 179, 184, 189, 194, 198, 203, 208, 214, 219, 224, 229, 234, 240, 245, 250
-};
-
-const float x264_log2_lut[128] =
-{
-    0.00000, 0.01123, 0.02237, 0.03342, 0.04439, 0.05528, 0.06609, 0.07682,
-    0.08746, 0.09803, 0.10852, 0.11894, 0.12928, 0.13955, 0.14975, 0.15987,
-    0.16993, 0.17991, 0.18982, 0.19967, 0.20945, 0.21917, 0.22882, 0.23840,
-    0.24793, 0.25739, 0.26679, 0.27612, 0.28540, 0.29462, 0.30378, 0.31288,
-    0.32193, 0.33092, 0.33985, 0.34873, 0.35755, 0.36632, 0.37504, 0.38370,
-    0.39232, 0.40088, 0.40939, 0.41785, 0.42626, 0.43463, 0.44294, 0.45121,
-    0.45943, 0.46761, 0.47573, 0.48382, 0.49185, 0.49985, 0.50779, 0.51570,
-    0.52356, 0.53138, 0.53916, 0.54689, 0.55459, 0.56224, 0.56986, 0.57743,
-    0.58496, 0.59246, 0.59991, 0.60733, 0.61471, 0.62205, 0.62936, 0.63662,
-    0.64386, 0.65105, 0.65821, 0.66534, 0.67243, 0.67948, 0.68650, 0.69349,
-    0.70044, 0.70736, 0.71425, 0.72110, 0.72792, 0.73471, 0.74147, 0.74819,
-    0.75489, 0.76155, 0.76818, 0.77479, 0.78136, 0.78790, 0.79442, 0.80090,
-    0.80735, 0.81378, 0.82018, 0.82655, 0.83289, 0.83920, 0.84549, 0.85175,
-    0.85798, 0.86419, 0.87036, 0.87652, 0.88264, 0.88874, 0.89482, 0.90087,
-    0.90689, 0.91289, 0.91886, 0.92481, 0.93074, 0.93664, 0.94251, 0.94837,
-    0.95420, 0.96000, 0.96578, 0.97154, 0.97728, 0.98299, 0.98868, 0.99435,
-};
-
-/* Avoid an int/float conversion. */
-const float x264_log2_lz_lut[32] =
-{
-    31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0
-};
-
-// should the intra and inter lambdas be different?
-// I'm just matching the behaviour of deadzone quant.
-static const int x264_trellis_lambda2_tab[2][QP_MAX_MAX+1] =
-{
-    // inter lambda = .85 * .85 * 2**(qp/3. + 10 - LAMBDA_BITS)
-    {
-               46,       58,       73,       92,      117,      147,
-              185,      233,      294,      370,      466,      587,
-              740,      932,     1174,     1480,     1864,     2349,
-             2959,     3728,     4697,     5918,     7457,     9395,
-            11837,    14914,    18790,    23674,    29828,    37581,
-            47349,    59656,    75163,    94699,   119313,   150326,
-           189399,   238627,   300652,   378798,   477255,   601304,
-           757596,   954511,  1202608,  1515192,  1909022,  2405217,
-          3030384,  3818045,  4810435,  6060769,  7636091,  9620872,
-         12121539, 15272182, 19241743, 24243077, 30544363, 38483486,
-         48486154, 61088726, 76966972, 96972308,
-        122177453,134217727,134217727,134217727,134217727,134217727,
-        134217727,134217727,134217727,134217727,134217727,134217727,
-    },
-    // intra lambda = .65 * .65 * 2**(qp/3. + 10 - LAMBDA_BITS)
-    {
-               27,       34,       43,       54,       68,       86,
-              108,      136,      172,      216,      273,      343,
-              433,      545,      687,      865,     1090,     1374,
-             1731,     2180,     2747,     3461,     4361,     5494,
-             6922,     8721,    10988,    13844,    17442,    21976,
-            27688,    34885,    43953,    55377,    69771,    87906,
-           110755,   139543,   175813,   221511,   279087,   351627,
-           443023,   558174,   703255,   886046,  1116348,  1406511,
-          1772093,  2232697,  2813022,  3544186,  4465396,  5626046,
-          7088374,  8930791, 11252092, 14176748, 17861583, 22504184,
-         28353495, 35723165, 45008368, 56706990,
-         71446330, 90016736,113413980,134217727,134217727,134217727,
-        134217727,134217727,134217727,134217727,134217727,134217727,
-        134217727,134217727,134217727,134217727,134217727,134217727,
-    }
-};
-
-#define MAX_CHROMA_LAMBDA_OFFSET 36
-static const uint16_t x264_chroma_lambda2_offset_tab[MAX_CHROMA_LAMBDA_OFFSET+1] =
-{
-       16,    20,    25,    32,    40,    50,
-       64,    80,   101,   128,   161,   203,
-      256,   322,   406,   512,   645,   812,
-     1024,  1290,  1625,  2048,  2580,  3250,
-     4096,  5160,  6501,  8192, 10321, 13003,
-    16384, 20642, 26007, 32768, 41285, 52015,
-    65535
-};
-
 /* TODO: calculate CABAC costs */
 static const uint8_t i_mb_b_cost_table[X264_MBTYPE_MAX] =
 {
index 05e3afb9e7e96c1cee36f8751f8a22af1f81df93..2dad00e89e697e5e7976332f54c5b94307bfba34 100644 (file)
 #ifndef X264_ANALYSE_H
 #define X264_ANALYSE_H
 
+#define x264_analyse_init_costs x264_template(analyse_init_costs)
 int x264_analyse_init_costs( x264_t *h );
+#define x264_analyse_free_costs x264_template(analyse_free_costs)
 void x264_analyse_free_costs( x264_t *h );
+#define x264_analyse_weight_frame x264_template(analyse_weight_frame)
 void x264_analyse_weight_frame( x264_t *h, int end );
+#define x264_macroblock_analyse x264_template(macroblock_analyse)
 void x264_macroblock_analyse( x264_t *h );
+#define x264_slicetype_decide x264_template(slicetype_decide)
 void x264_slicetype_decide( x264_t *h );
 
+#define x264_slicetype_analyse x264_template(slicetype_analyse)
 void x264_slicetype_analyse( x264_t *h, int intra_minigop );
 
+#define x264_lookahead_init x264_template(lookahead_init)
 int  x264_lookahead_init( x264_t *h, int i_slicetype_length );
+#define x264_lookahead_is_empty x264_template(lookahead_is_empty)
 int  x264_lookahead_is_empty( x264_t *h );
+#define x264_lookahead_put_frame x264_template(lookahead_put_frame)
 void x264_lookahead_put_frame( x264_t *h, x264_frame_t *frame );
+#define x264_lookahead_get_frames x264_template(lookahead_get_frames)
 void x264_lookahead_get_frames( x264_t *h );
+#define x264_lookahead_delete x264_template(lookahead_delete)
 void x264_lookahead_delete( x264_t *h );
 
 #endif
diff --git a/encoder/api.c b/encoder/api.c
new file mode 100644 (file)
index 0000000..3396051
--- /dev/null
@@ -0,0 +1,194 @@
+/*****************************************************************************
+ * api.c: bit depth independent interface
+ *****************************************************************************
+ * Copyright (C) 2003-2017 x264 project
+ *
+ * Authors: Vittorio Giovara <vittorio.giovara@gmail.com>
+ *          Luca Barbato <lu_zero@gentoo.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@x264.com.
+ *****************************************************************************/
+
+#include "common/base.h"
+
+/****************************************************************************
+ * global symbols
+ ****************************************************************************/
+const int x264_chroma_format = X264_CHROMA_FORMAT;
+
+x264_t *x264_8_encoder_open( x264_param_t * );
+void x264_8_nal_encode( x264_t *h, uint8_t *dst, x264_nal_t *nal );
+int  x264_8_encoder_reconfig( x264_t *, x264_param_t * );
+void x264_8_encoder_parameters( x264_t *, x264_param_t * );
+int  x264_8_encoder_headers( x264_t *, x264_nal_t **pp_nal, int *pi_nal );
+int  x264_8_encoder_encode( x264_t *, x264_nal_t **pp_nal, int *pi_nal, x264_picture_t *pic_in, x264_picture_t *pic_out );
+void x264_8_encoder_close( x264_t * );
+int  x264_8_encoder_delayed_frames( x264_t * );
+int  x264_8_encoder_maximum_delayed_frames( x264_t * );
+void x264_8_encoder_intra_refresh( x264_t * );
+int  x264_8_encoder_invalidate_reference( x264_t *, int64_t pts );
+
+x264_t *x264_10_encoder_open( x264_param_t * );
+void x264_10_nal_encode( x264_t *h, uint8_t *dst, x264_nal_t *nal );
+int  x264_10_encoder_reconfig( x264_t *, x264_param_t * );
+void x264_10_encoder_parameters( x264_t *, x264_param_t * );
+int  x264_10_encoder_headers( x264_t *, x264_nal_t **pp_nal, int *pi_nal );
+int  x264_10_encoder_encode( x264_t *, x264_nal_t **pp_nal, int *pi_nal, x264_picture_t *pic_in, x264_picture_t *pic_out );
+void x264_10_encoder_close( x264_t * );
+int  x264_10_encoder_delayed_frames( x264_t * );
+int  x264_10_encoder_maximum_delayed_frames( x264_t * );
+void x264_10_encoder_intra_refresh( x264_t * );
+int  x264_10_encoder_invalidate_reference( x264_t *, int64_t pts );
+
+typedef struct x264_api_t
+{
+    /* Internal reference to x264_t data */
+    x264_t *x264;
+
+    /* API entry points */
+    void (*nal_encode)( x264_t *h, uint8_t *dst, x264_nal_t *nal );
+    int  (*encoder_reconfig)( x264_t *, x264_param_t * );
+    void (*encoder_parameters)( x264_t *, x264_param_t * );
+    int  (*encoder_headers)( x264_t *, x264_nal_t **pp_nal, int *pi_nal );
+    int  (*encoder_encode)( x264_t *, x264_nal_t **pp_nal, int *pi_nal, x264_picture_t *pic_in, x264_picture_t *pic_out );
+    void (*encoder_close)( x264_t * );
+    int  (*encoder_delayed_frames)( x264_t * );
+    int  (*encoder_maximum_delayed_frames)( x264_t * );
+    void (*encoder_intra_refresh)( x264_t * );
+    int  (*encoder_invalidate_reference)( x264_t *, int64_t pts );
+} x264_api_t;
+
+x264_t *x264_encoder_open( x264_param_t *param )
+{
+    x264_api_t *api = calloc( 1, sizeof( x264_api_t ) );
+    if( !api )
+        return NULL;
+
+    if( HAVE_BITDEPTH8 && param->i_bitdepth == 8 )
+    {
+        api->nal_encode = x264_8_nal_encode;
+        api->encoder_reconfig = x264_8_encoder_reconfig;
+        api->encoder_parameters = x264_8_encoder_parameters;
+        api->encoder_headers = x264_8_encoder_headers;
+        api->encoder_encode = x264_8_encoder_encode;
+        api->encoder_close = x264_8_encoder_close;
+        api->encoder_delayed_frames = x264_8_encoder_delayed_frames;
+        api->encoder_maximum_delayed_frames = x264_8_encoder_maximum_delayed_frames;
+        api->encoder_intra_refresh = x264_8_encoder_intra_refresh;
+        api->encoder_invalidate_reference = x264_8_encoder_invalidate_reference;
+
+        api->x264 = x264_8_encoder_open( param );
+    }
+    else if( HAVE_BITDEPTH10 && param->i_bitdepth == 10 )
+    {
+        api->nal_encode = x264_10_nal_encode;
+        api->encoder_reconfig = x264_10_encoder_reconfig;
+        api->encoder_parameters = x264_10_encoder_parameters;
+        api->encoder_headers = x264_10_encoder_headers;
+        api->encoder_encode = x264_10_encoder_encode;
+        api->encoder_close = x264_10_encoder_close;
+        api->encoder_delayed_frames = x264_10_encoder_delayed_frames;
+        api->encoder_maximum_delayed_frames = x264_10_encoder_maximum_delayed_frames;
+        api->encoder_intra_refresh = x264_10_encoder_intra_refresh;
+        api->encoder_invalidate_reference = x264_10_encoder_invalidate_reference;
+
+        api->x264 = x264_10_encoder_open( param );
+    }
+    else
+        x264_log_internal( X264_LOG_ERROR, "not compiled with %d bit depth support\n", param->i_bitdepth );
+
+    if( !api->x264 )
+    {
+        free( api );
+        return NULL;
+    }
+
+    /* x264_t is opaque */
+    return (x264_t *)api;
+}
+
+void x264_encoder_close( x264_t *h )
+{
+    x264_api_t *api = (x264_api_t *)h;
+
+    api->encoder_close( api->x264 );
+    free( api );
+}
+
+void x264_nal_encode( x264_t *h, uint8_t *dst, x264_nal_t *nal )
+{
+    x264_api_t *api = (x264_api_t *)h;
+
+    api->nal_encode( api->x264, dst, nal );
+}
+
+int x264_encoder_reconfig( x264_t *h, x264_param_t *param)
+{
+    x264_api_t *api = (x264_api_t *)h;
+
+    return api->encoder_reconfig( api->x264, param );
+}
+
+void x264_encoder_parameters( x264_t *h, x264_param_t *param )
+{
+    x264_api_t *api = (x264_api_t *)h;
+
+    api->encoder_parameters( api->x264, param );
+}
+
+int x264_encoder_headers( x264_t *h, x264_nal_t **pp_nal, int *pi_nal )
+{
+    x264_api_t *api = (x264_api_t *)h;
+
+    return api->encoder_headers( api->x264, pp_nal, pi_nal );
+}
+
+int x264_encoder_encode( x264_t *h, x264_nal_t **pp_nal, int *pi_nal, x264_picture_t *pic_in, x264_picture_t *pic_out )
+{
+    x264_api_t *api = (x264_api_t *)h;
+
+    return api->encoder_encode( api->x264, pp_nal, pi_nal, pic_in, pic_out );
+}
+
+int x264_encoder_delayed_frames( x264_t *h )
+{
+    x264_api_t *api = (x264_api_t *)h;
+
+    return api->encoder_delayed_frames( api->x264 );
+}
+
+int x264_encoder_maximum_delayed_frames( x264_t *h )
+{
+    x264_api_t *api = (x264_api_t *)h;
+
+    return api->encoder_maximum_delayed_frames( api->x264 );
+}
+
+void x264_encoder_intra_refresh( x264_t *h )
+{
+    x264_api_t *api = (x264_api_t *)h;
+
+    api->encoder_intra_refresh( api->x264 );
+}
+
+int x264_encoder_invalidate_reference( x264_t *h, int64_t pts )
+{
+    x264_api_t *api = (x264_api_t *)h;
+
+    return api->encoder_invalidate_reference( api->x264, pts );
+}
index 2465a5e6ab4b1eeab0726d79fed25630bb9c7916..82087c2847aaf58669f5e2cb168076d0db4995c0 100644 (file)
@@ -644,53 +644,6 @@ static int ALWAYS_INLINE cabac_cbf_ctxidxinc( x264_t *h, int i_cat, int i_idx, i
     }
 }
 
-#if !RDO_SKIP_BS
-extern const uint8_t x264_significant_coeff_flag_offset_8x8[2][64];
-extern const uint8_t x264_last_coeff_flag_offset_8x8[63];
-extern const uint8_t x264_coeff_flag_offset_chroma_422_dc[7];
-extern const uint16_t x264_significant_coeff_flag_offset[2][16];
-extern const uint16_t x264_last_coeff_flag_offset[2][16];
-extern const uint16_t x264_coeff_abs_level_m1_offset[16];
-extern const uint8_t x264_count_cat_m1[14];
-#else
-/* Padded to [64] for easier addressing */
-const uint8_t x264_significant_coeff_flag_offset_8x8[2][64] =
-{{
-    0, 1, 2, 3, 4, 5, 5, 4, 4, 3, 3, 4, 4, 4, 5, 5,
-    4, 4, 4, 4, 3, 3, 6, 7, 7, 7, 8, 9,10, 9, 8, 7,
-    7, 6,11,12,13,11, 6, 7, 8, 9,14,10, 9, 8, 6,11,
-   12,13,11, 6, 9,14,10, 9,11,12,13,11,14,10,12
-},{
-    0, 1, 1, 2, 2, 3, 3, 4, 5, 6, 7, 7, 7, 8, 4, 5,
-    6, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,11,12,11,
-    9, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,13,13, 9,
-    9,10,10, 8,13,13, 9, 9,10,10,14,14,14,14,14
-}};
-const uint8_t x264_last_coeff_flag_offset_8x8[63] =
-{
-    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-    3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
-    5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8
-};
-const uint8_t x264_coeff_flag_offset_chroma_422_dc[7] = { 0, 0, 1, 1, 2, 2, 2 }; /* MIN( i/2, 2 ) */
-const uint16_t x264_significant_coeff_flag_offset[2][16] =
-{
-    { 105+0, 105+15, 105+29, 105+44, 105+47, 402, 484+0, 484+15, 484+29, 660, 528+0, 528+15, 528+29, 718, 0, 0 },
-    { 277+0, 277+15, 277+29, 277+44, 277+47, 436, 776+0, 776+15, 776+29, 675, 820+0, 820+15, 820+29, 733, 0, 0 }
-};
-const uint16_t x264_last_coeff_flag_offset[2][16] =
-{
-    { 166+0, 166+15, 166+29, 166+44, 166+47, 417, 572+0, 572+15, 572+29, 690, 616+0, 616+15, 616+29, 748, 0, 0 },
-    { 338+0, 338+15, 338+29, 338+44, 338+47, 451, 864+0, 864+15, 864+29, 699, 908+0, 908+15, 908+29, 757, 0, 0 }
-};
-const uint16_t x264_coeff_abs_level_m1_offset[16] =
-{
-    227+0, 227+10, 227+20, 227+30, 227+39, 426, 952+0, 952+10, 952+20, 708, 982+0, 982+10, 982+20, 766
-};
-const uint8_t x264_count_cat_m1[14] = {15, 14, 15, 3, 14, 63, 15, 14, 15, 63, 15, 14, 15, 63};
-#endif
-
 // node ctx: 0..3: abslevel1 (with abslevelgt1 == 0).
 //           4..7: abslevelgt1 + 3 (and abslevel1 doesn't matter).
 /* map node ctx => cabac ctx for level=1 */
index 3ddf89caaa3804bd28f030e2c00d84f4d38f1422..b1be6359acf551abafcd90f3b951ddcc571dba3e 100644 (file)
 
 #define bs_write_ue bs_write_ue_big
 
+// forward declaration needed for template usage
+void x264_nal_encode( x264_t *h, uint8_t *dst, x264_nal_t *nal );
+void x264_macroblock_cache_load_progressive( x264_t *h, int i_mb_x, int i_mb_y );
+
 static int encoder_frame_end( x264_t *h, x264_t *thread_current,
                               x264_nal_t **pp_nal, int *pi_nal,
                               x264_picture_t *pic_out );
@@ -422,7 +426,7 @@ static int validate_parameters( x264_t *h, int b_open )
 {
     if( !h->param.pf_log )
     {
-        x264_log( NULL, X264_LOG_ERROR, "pf_log not set! did you forget to call x264_param_default?\n" );
+        x264_log_internal( X264_LOG_ERROR, "pf_log not set! did you forget to call x264_param_default?\n" );
         return -1;
     }
 
index 1c901a899b34c0a5e1d77d7104e5443a7d71d1d0..16febe155bfc7ab625b3bf72a2e0cf5f362e4825 100644 (file)
 
 #include "common/macroblock.h"
 
-extern const int x264_lambda2_tab[QP_MAX_MAX+1];
-extern const uint16_t x264_lambda_tab[QP_MAX_MAX+1];
-
+#define x264_rdo_init x264_template(rdo_init)
 void x264_rdo_init( void );
 
+#define x264_macroblock_probe_skip x264_template(macroblock_probe_skip)
 int x264_macroblock_probe_skip( x264_t *h, int b_bidir );
 
 #define x264_macroblock_probe_pskip( h )\
@@ -41,32 +40,51 @@ int x264_macroblock_probe_skip( x264_t *h, int b_bidir );
 #define x264_macroblock_probe_bskip( h )\
     x264_macroblock_probe_skip( h, 1 )
 
+#define x264_predict_lossless_4x4 x264_template(predict_lossless_4x4)
 void x264_predict_lossless_4x4( x264_t *h, pixel *p_dst, int p, int idx, int i_mode );
+#define x264_predict_lossless_8x8 x264_template(predict_lossless_8x8)
 void x264_predict_lossless_8x8( x264_t *h, pixel *p_dst, int p, int idx, int i_mode, pixel edge[36] );
+#define x264_predict_lossless_16x16 x264_template(predict_lossless_16x16)
 void x264_predict_lossless_16x16( x264_t *h, int p, int i_mode );
+#define x264_predict_lossless_chroma x264_template(predict_lossless_chroma)
 void x264_predict_lossless_chroma( x264_t *h, int i_mode );
 
+#define x264_macroblock_encode x264_template(macroblock_encode)
 void x264_macroblock_encode      ( x264_t *h );
+#define x264_macroblock_write_cabac x264_template(macroblock_write_cabac)
 void x264_macroblock_write_cabac ( x264_t *h, x264_cabac_t *cb );
+#define x264_macroblock_write_cavlc x264_template(macroblock_write_cavlc)
 void x264_macroblock_write_cavlc ( x264_t *h );
 
+#define x264_macroblock_encode_p8x8 x264_template(macroblock_encode_p8x8)
 void x264_macroblock_encode_p8x8( x264_t *h, int i8 );
+#define x264_macroblock_encode_p4x4 x264_template(macroblock_encode_p4x4)
 void x264_macroblock_encode_p4x4( x264_t *h, int i4 );
+#define x264_mb_encode_chroma x264_template(mb_encode_chroma)
 void x264_mb_encode_chroma( x264_t *h, int b_inter, int i_qp );
 
+#define x264_cabac_mb_skip x264_template(cabac_mb_skip)
 void x264_cabac_mb_skip( x264_t *h, int b_skip );
+#define x264_cabac_block_residual_c x264_template(cabac_block_residual_c)
 void x264_cabac_block_residual_c( x264_t *h, x264_cabac_t *cb, int ctx_block_cat, dctcoef *l );
+#define x264_cabac_block_residual_8x8_rd_c x264_template(cabac_block_residual_8x8_rd_c)
 void x264_cabac_block_residual_8x8_rd_c( x264_t *h, x264_cabac_t *cb, int ctx_block_cat, dctcoef *l );
+#define x264_cabac_block_residual_rd_c x264_template(cabac_block_residual_rd_c)
 void x264_cabac_block_residual_rd_c( x264_t *h, x264_cabac_t *cb, int ctx_block_cat, dctcoef *l );
 
+#define x264_quant_luma_dc_trellis x264_template(quant_luma_dc_trellis)
 int x264_quant_luma_dc_trellis( x264_t *h, dctcoef *dct, int i_quant_cat, int i_qp,
                                 int ctx_block_cat, int b_intra, int idx );
+#define x264_quant_chroma_dc_trellis x264_template(quant_chroma_dc_trellis)
 int x264_quant_chroma_dc_trellis( x264_t *h, dctcoef *dct, int i_qp, int b_intra, int idx );
+#define x264_quant_4x4_trellis x264_template(quant_4x4_trellis)
 int x264_quant_4x4_trellis( x264_t *h, dctcoef *dct, int i_quant_cat,
                              int i_qp, int ctx_block_cat, int b_intra, int b_chroma, int idx );
+#define x264_quant_8x8_trellis x264_template(quant_8x8_trellis)
 int x264_quant_8x8_trellis( x264_t *h, dctcoef *dct, int i_quant_cat,
                              int i_qp, int ctx_block_cat, int b_intra, int b_chroma, int idx );
 
+#define x264_noise_reduction_update x264_template(noise_reduction_update)
 void x264_noise_reduction_update( x264_t *h );
 
 static ALWAYS_INLINE int x264_quant_4x4( x264_t *h, dctcoef dct[16], int i_qp, int ctx_block_cat, int b_intra, int p, int idx )
index b082f203fecaa9ad8c523cbaab463ad012e240c3..fbb694b683191f36e5ab2fe6e929470dc03feb2b 100644 (file)
@@ -1022,6 +1022,7 @@ static void refine_subpel( x264_t *h, x264_me_t *m, int hpel_iters, int qpel_ite
 
 /* Don't unroll the BIME_CACHE loop. I couldn't find any way to force this
  * other than making its iteration count not a compile-time constant. */
+#define x264_iter_kludge x264_template(iter_kludge)
 int x264_iter_kludge = 0;
 
 static void ALWAYS_INLINE me_refine_bidir( x264_t *h, x264_me_t *m0, x264_me_t *m1, int i_weight, int i8, int i_lambda2, int rd )
index 505e3ce142f59d367f5599aa7f12cec670c80511..277291caf9ad021b22e9ebecf4bed38080bb3356 100644 (file)
@@ -55,15 +55,22 @@ typedef struct
     ALIGNED_4( int16_t mv[2] );
 } ALIGNED_64( x264_me_t );
 
+#define x264_me_search_ref x264_template(me_search_ref)
 void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc, int *p_fullpel_thresh );
 #define x264_me_search( h, m, mvc, i_mvc )\
     x264_me_search_ref( h, m, mvc, i_mvc, NULL )
 
+#define x264_me_refine_qpel x264_template(me_refine_qpel)
 void x264_me_refine_qpel( x264_t *h, x264_me_t *m );
+#define x264_me_refine_qpel_refdupe x264_template(me_refine_qpel_refdupe)
 void x264_me_refine_qpel_refdupe( x264_t *h, x264_me_t *m, int *p_halfpel_thresh );
+#define x264_me_refine_qpel_rd x264_template(me_refine_qpel_rd)
 void x264_me_refine_qpel_rd( x264_t *h, x264_me_t *m, int i_lambda2, int i4, int i_list );
+#define x264_me_refine_bidir_rd x264_template(me_refine_bidir_rd)
 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 );
+#define x264_me_refine_bidir_satd x264_template(me_refine_bidir_satd)
 void x264_me_refine_bidir_satd( x264_t *h, x264_me_t *m0, x264_me_t *m1, int i_weight );
+#define x264_rd_cost_part x264_template(rd_cost_part)
 uint64_t x264_rd_cost_part( x264_t *h, int i_lambda2, int i8, int i_pixel );
 
 #define COPY1_IF_LT(x,y)\
index 168b515ca589e9e1f1aab20e48628850e290dc77..e2415082f1aca4f077ea6ae11568ca234c8a04ec 100644 (file)
 
 #define CLIP_DURATION(f) x264_clip3f(f,MIN_FRAME_DURATION,MAX_FRAME_DURATION)
 
+#define x264_ratecontrol_new x264_template(ratecontrol_new)
 int  x264_ratecontrol_new   ( x264_t * );
+#define x264_ratecontrol_delete x264_template(ratecontrol_delete)
 void x264_ratecontrol_delete( x264_t * );
 
+#define x264_ratecontrol_init_reconfigurable x264_template(ratecontrol_init_reconfigurable)
 void x264_ratecontrol_init_reconfigurable( x264_t *h, int b_init );
+#define x264_encoder_reconfig_apply x264_template(encoder_reconfig_apply)
 int x264_encoder_reconfig_apply( x264_t *h, x264_param_t *param );
 
+#define x264_adaptive_quant_frame x264_template(adaptive_quant_frame)
 void x264_adaptive_quant_frame( x264_t *h, x264_frame_t *frame, float *quant_offsets );
+#define x264_macroblock_tree_read x264_template(macroblock_tree_read)
 int  x264_macroblock_tree_read( x264_t *h, x264_frame_t *frame, float *quant_offsets );
+#define x264_reference_build_list_optimal x264_template(reference_build_list_optimal)
 int  x264_reference_build_list_optimal( x264_t *h );
+#define x264_thread_sync_ratecontrol x264_template(thread_sync_ratecontrol)
 void x264_thread_sync_ratecontrol( x264_t *cur, x264_t *prev, x264_t *next );
+#define x264_ratecontrol_zone_init x264_template(ratecontrol_zone_init)
 void x264_ratecontrol_zone_init( x264_t * );
+#define x264_ratecontrol_start x264_template(ratecontrol_start)
 void x264_ratecontrol_start( x264_t *, int i_force_qp, int overhead );
+#define x264_ratecontrol_slice_type x264_template(ratecontrol_slice_type)
 int  x264_ratecontrol_slice_type( x264_t *, int i_frame );
+#define x264_ratecontrol_set_weights x264_template(ratecontrol_set_weights)
 void x264_ratecontrol_set_weights( x264_t *h, x264_frame_t *frm );
+#define x264_ratecontrol_mb x264_template(ratecontrol_mb)
 int  x264_ratecontrol_mb( x264_t *, int bits );
+#define x264_ratecontrol_qp x264_template(ratecontrol_qp)
 int  x264_ratecontrol_qp( x264_t * );
+#define x264_ratecontrol_mb_qp x264_template(ratecontrol_mb_qp)
 int  x264_ratecontrol_mb_qp( x264_t *h );
+#define x264_ratecontrol_end x264_template(ratecontrol_end)
 int  x264_ratecontrol_end( x264_t *, int bits, int *filler );
+#define x264_ratecontrol_summary x264_template(ratecontrol_summary)
 void x264_ratecontrol_summary( x264_t * );
+#define x264_rc_analyse_slice x264_template(rc_analyse_slice)
 int  x264_rc_analyse_slice( x264_t *h );
+#define x264_threads_distribute_ratecontrol x264_template(threads_distribute_ratecontrol)
 void x264_threads_distribute_ratecontrol( x264_t *h );
+#define x264_threads_merge_ratecontrol x264_template(threads_merge_ratecontrol)
 void x264_threads_merge_ratecontrol( x264_t *h );
+#define x264_hrd_fullness x264_template(hrd_fullness)
 void x264_hrd_fullness( x264_t *h );
+
 #endif
 
index 23cfb2bd3a9033d705e7d255e6c06d302b47b049..bc92fdee6c3291e6e7b58dfcb19768a7eccfeeed 100644 (file)
@@ -32,7 +32,9 @@
 
 /* Transition and size tables for abs<9 MVD and residual coding */
 /* Consist of i_prefix-2 1s, one zero, and a bypass sign bit */
+#define x264_cabac_transition_unary x264_template(cabac_transition_unary)
 uint8_t x264_cabac_transition_unary[15][128];
+#define x264_cabac_size_unary x264_template(cabac_size_unary)
 uint16_t x264_cabac_size_unary[15][128];
 /* Transition and size tables for abs>9 MVD */
 /* Consist of 5 1s and a bypass sign bit */
@@ -46,6 +48,7 @@ static uint16_t cabac_size_5ones[128];
 #define bs_write_ue(s,v)   ((s)->i_bits_encoded += bs_size_ue(v))
 #define bs_write_se(s,v)   ((s)->i_bits_encoded += bs_size_se(v))
 #define bs_write_te(s,v,l) ((s)->i_bits_encoded += bs_size_te(v,l))
+#undef  x264_macroblock_write_cavlc
 #define x264_macroblock_write_cavlc  static macroblock_size_cavlc
 #include "cavlc.c"
 
@@ -55,11 +58,13 @@ static uint16_t cabac_size_5ones[128];
 #undef  x264_cabac_encode_decision_noup
 #undef  x264_cabac_encode_bypass
 #undef  x264_cabac_encode_terminal
+#undef  x264_cabac_encode_ue_bypass
 #define x264_cabac_encode_decision(c,x,v) x264_cabac_size_decision(c,x,v)
 #define x264_cabac_encode_decision_noup(c,x,v) x264_cabac_size_decision_noup(c,x,v)
 #define x264_cabac_encode_terminal(c)     ((c)->f8_bits_encoded += 7)
 #define x264_cabac_encode_bypass(c,v)     ((c)->f8_bits_encoded += 256)
 #define x264_cabac_encode_ue_bypass(c,e,v) ((c)->f8_bits_encoded += (bs_size_ue_big(v+(1<<e)-1)-e)<<8)
+#undef  x264_macroblock_write_cabac
 #define x264_macroblock_write_cabac  static macroblock_size_cabac
 #include "cabac.c"
 
index 2ab4e4e84aec6641d4750bc7e16f6bd56a5ae305..07cb4c4419d6c4deeab3dda098a053b621e310a2 100644 (file)
@@ -781,31 +781,6 @@ int x264_sei_avcintra_vanc_write( x264_t *h, bs_t *s, int len )
     return 0;
 }
 
-const x264_level_t x264_levels[] =
-{
-    { 10,     1485,     99,    396,     64,    175,   64, 64,  0, 2, 0, 0, 1 },
-    {  9,     1485,     99,    396,    128,    350,   64, 64,  0, 2, 0, 0, 1 }, /* "1b" */
-    { 11,     3000,    396,    900,    192,    500,  128, 64,  0, 2, 0, 0, 1 },
-    { 12,     6000,    396,   2376,    384,   1000,  128, 64,  0, 2, 0, 0, 1 },
-    { 13,    11880,    396,   2376,    768,   2000,  128, 64,  0, 2, 0, 0, 1 },
-    { 20,    11880,    396,   2376,   2000,   2000,  128, 64,  0, 2, 0, 0, 1 },
-    { 21,    19800,    792,   4752,   4000,   4000,  256, 64,  0, 2, 0, 0, 0 },
-    { 22,    20250,   1620,   8100,   4000,   4000,  256, 64,  0, 2, 0, 0, 0 },
-    { 30,    40500,   1620,   8100,  10000,  10000,  256, 32, 22, 2, 0, 1, 0 },
-    { 31,   108000,   3600,  18000,  14000,  14000,  512, 16, 60, 4, 1, 1, 0 },
-    { 32,   216000,   5120,  20480,  20000,  20000,  512, 16, 60, 4, 1, 1, 0 },
-    { 40,   245760,   8192,  32768,  20000,  25000,  512, 16, 60, 4, 1, 1, 0 },
-    { 41,   245760,   8192,  32768,  50000,  62500,  512, 16, 24, 2, 1, 1, 0 },
-    { 42,   522240,   8704,  34816,  50000,  62500,  512, 16, 24, 2, 1, 1, 1 },
-    { 50,   589824,  22080, 110400, 135000, 135000,  512, 16, 24, 2, 1, 1, 1 },
-    { 51,   983040,  36864, 184320, 240000, 240000,  512, 16, 24, 2, 1, 1, 1 },
-    { 52,  2073600,  36864, 184320, 240000, 240000,  512, 16, 24, 2, 1, 1, 1 },
-    { 60,  4177920, 139264, 696320, 240000, 240000, 8192, 16, 24, 2, 1, 1, 1 },
-    { 61,  8355840, 139264, 696320, 480000, 480000, 8192, 16, 24, 2, 1, 1, 1 },
-    { 62, 16711680, 139264, 696320, 800000, 800000, 8192, 16, 24, 2, 1, 1, 1 },
-    { 0 }
-};
-
 #define ERROR(...)\
 {\
     if( verbose )\
index 8e11655d125fd46c23e2eccf57df52cebcb8e254..20b7481336d72baeeb4d8e5c18a3a284539de2e4 100644 (file)
 #ifndef X264_ENCODER_SET_H
 #define X264_ENCODER_SET_H
 
+#define x264_sps_init x264_template(sps_init)
 void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param );
+#define x264_sps_init_reconfigurable x264_template(sps_init_reconfigurable)
 void x264_sps_init_reconfigurable( x264_sps_t *sps, x264_param_t *param );
+#define x264_sps_write x264_template(sps_write)
 void x264_sps_write( bs_t *s, x264_sps_t *sps );
+#define x264_pps_init x264_template(pps_init)
 void x264_pps_init( x264_pps_t *pps, int i_id, x264_param_t *param, x264_sps_t *sps );
+#define x264_pps_write x264_template(pps_write)
 void x264_pps_write( bs_t *s, x264_sps_t *sps, x264_pps_t *pps );
+#define x264_sei_recovery_point_write x264_template(sei_recovery_point_write)
 void x264_sei_recovery_point_write( x264_t *h, bs_t *s, int recovery_frame_cnt );
+#define x264_sei_version_write x264_template(sei_version_write)
 int  x264_sei_version_write( x264_t *h, bs_t *s );
+#define x264_validate_levels x264_template(validate_levels)
 int  x264_validate_levels( x264_t *h, int verbose );
+#define x264_sei_buffering_period_write x264_template(sei_buffering_period_write)
 void x264_sei_buffering_period_write( x264_t *h, bs_t *s );
+#define x264_sei_pic_timing_write x264_template(sei_pic_timing_write)
 void x264_sei_pic_timing_write( x264_t *h, bs_t *s );
+#define x264_sei_dec_ref_pic_marking_write x264_template(sei_dec_ref_pic_marking_write)
 void x264_sei_dec_ref_pic_marking_write( x264_t *h, bs_t *s );
+#define x264_sei_frame_packing_write x264_template(sei_frame_packing_write)
 void x264_sei_frame_packing_write( x264_t *h, bs_t *s );
+#define x264_sei_avcintra_umid_write x264_template(sei_avcintra_umid_write)
 int  x264_sei_avcintra_umid_write( x264_t *h, bs_t *s );
+#define x264_sei_avcintra_vanc_write x264_template(sei_avcintra_vanc_write)
 int  x264_sei_avcintra_vanc_write( x264_t *h, bs_t *s, int len );
+#define x264_sei_write x264_template(sei_write)
 void x264_sei_write( bs_t *s, uint8_t *payload, int payload_size, int payload_type );
+#define x264_filler_write x264_template(filler_write)
 void x264_filler_write( x264_t *h, bs_t *s, int filler );
 
 #endif
index 80dc6ece17c6eca5ba2f82afd0d2f49b43e3eb4b..bd671259613281053a45846c45ad325e22c98d44 100644 (file)
 #include "common/common.h"
 #include "macroblock.h"
 #include "me.h"
+#include "slicetype-cl.h"
 
 #if HAVE_OPENCL
 #ifdef _WIN32
 #include <windows.h>
 #endif
 
+#define x264_weights_analyse x264_template(weights_analyse)
 void x264_weights_analyse( x264_t *h, x264_frame_t *fenc, x264_frame_t *ref, int b_lookahead );
 
 /* We define CL_QUEUE_THREAD_HANDLE_AMD here because it is not defined
diff --git a/encoder/slicetype-cl.h b/encoder/slicetype-cl.h
new file mode 100644 (file)
index 0000000..896cff1
--- /dev/null
@@ -0,0 +1,44 @@
+/*****************************************************************************
+ * slicetype-cl.h: OpenCL slicetype decision code (lowres lookahead)
+ *****************************************************************************
+ * Copyright (C) 2017 x264 project
+ *
+ * Authors: Anton Mitrofanov <BugMaster@narod.ru>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@x264.com.
+ *****************************************************************************/
+
+#ifndef X264_ENCODER_SLICETYPE_CL_H
+#define X264_ENCODER_SLICETYPE_CL_H
+
+#define x264_opencl_lowres_init x264_template(opencl_lowres_init)
+int x264_opencl_lowres_init( x264_t *h, x264_frame_t *fenc, int lambda );
+#define x264_opencl_motionsearch x264_template(opencl_motionsearch)
+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 );
+#define x264_opencl_finalize_cost x264_template(opencl_finalize_cost)
+int x264_opencl_finalize_cost( x264_t *h, int lambda, x264_frame_t **frames, int p0, int p1, int b, int dist_scale_factor );
+#define x264_opencl_precalculate_frame_cost x264_template(opencl_precalculate_frame_cost)
+int x264_opencl_precalculate_frame_cost( x264_t *h, x264_frame_t **frames, int lambda, int p0, int p1, int b );
+#define x264_opencl_flush x264_template(opencl_flush)
+void x264_opencl_flush( x264_t *h );
+#define x264_opencl_slicetype_prep x264_template(opencl_slicetype_prep)
+void x264_opencl_slicetype_prep( x264_t *h, x264_frame_t **frames, int num_frames, int lambda );
+#define x264_opencl_slicetype_end x264_template(opencl_slicetype_end)
+void x264_opencl_slicetype_end( x264_t *h );
+
+#endif
index 0301f09600556e9e1c5dc278fc233911651b8a39..bbae776e6ee1d2cae08cd4dfa3deee46bbf9fab7 100644 (file)
@@ -35,16 +35,11 @@ static const uint8_t delta_tfi_divisor[10] = { 0, 2, 1, 1, 2, 2, 3, 3, 4, 6 };
 static int slicetype_frame_cost( x264_t *h, x264_mb_analysis_t *a,
                                       x264_frame_t **frames, int p0, int p1, int b );
 
+#define x264_weights_analyse x264_template(weights_analyse)
 void x264_weights_analyse( x264_t *h, x264_frame_t *fenc, x264_frame_t *ref, int b_lookahead );
 
 #if HAVE_OPENCL
-int x264_opencl_lowres_init( x264_t *h, x264_frame_t *fenc, int lambda );
-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 );
-int x264_opencl_finalize_cost( x264_t *h, int lambda, x264_frame_t **frames, int p0, int p1, int b, int dist_scale_factor );
-int x264_opencl_precalculate_frame_cost( x264_t *h, x264_frame_t **frames, int lambda, int p0, int p1, int b );
-void x264_opencl_flush( x264_t *h );
-void x264_opencl_slicetype_prep( x264_t *h, x264_frame_t **frames, int num_frames, int lambda );
-void x264_opencl_slicetype_end( x264_t *h );
+#include "slicetype-cl.h"
 #endif
 
 static void lowres_context_init( x264_t *h, x264_mb_analysis_t *a )
index 0fb7fbdb2ab7158de4e53e0ca897260efdd10fb4..afc21d8d9b9a5e8ae40fb7910cfe5b30a7b2761a 100644 (file)
--- a/example.c
+++ b/example.c
@@ -68,6 +68,7 @@ int main( int argc, char **argv )
         goto fail;
 
     /* Configure non-default params */
+    param.i_bitdepth = 8;
     param.i_csp = X264_CSP_I420;
     param.i_width  = width;
     param.i_height = height;
index 9212a3e091220f018a4522d7fb81a5a5a3ef9e47..fc5e7a592917e0fa9de1bdc3df85e4d7312b1616 100644 (file)
@@ -26,6 +26,7 @@
  *****************************************************************************/
 
 #include "filters.h"
+
 #define RETURN_IF_ERROR( cond, ... ) RETURN_IF_ERR( cond, "options", NULL, __VA_ARGS__ )
 
 char **x264_split_options( const char *opt_str, const char * const *options )
index 552e1b4777061a0447654424746c6fadcd15b7e7..9170d6dbb21510b2232bca8a5018015f4e9eb943 100644 (file)
 
 #include "video.h"
 #include "internal.h"
-#define NAME "cache"
+#include "common/common.h"
+
+#define cache_filter x264_glue3(cache, BIT_DEPTH, filter)
+#if BIT_DEPTH == 8
+#define NAME "cache_8"
+#else
+#define NAME "cache_10"
+#endif
+
 #define LAST_FRAME (h->first_frame + h->cur_size - 1)
 
 typedef struct
index c39914ab893de925ebca854e57a34233b968954b..8a00e2d89014d036873c2bdf09625a8c2986cffc 100644 (file)
@@ -25,6 +25,7 @@
  *****************************************************************************/
 
 #include "video.h"
+
 #define NAME "crop"
 #define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, NAME, __VA_ARGS__ )
 
index 72eb288d99022467db3e66917eff143c514a2938..f56dc45eb99ba7e5b6e81f3a3f4f10450a6fae07 100644 (file)
  *****************************************************************************/
 
 #include "video.h"
-#define NAME "depth"
+#include "common/common.h"
+
+#define depth_filter x264_glue3(depth, BIT_DEPTH, filter)
+#if BIT_DEPTH == 8
+#define NAME "depth_8"
+#else
+#define NAME "depth_10"
+#endif
+
 #define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, NAME, __VA_ARGS__ )
 
 cli_vid_filter_t depth_filter;
@@ -74,10 +82,10 @@ static int csp_num_interleaved( int csp, int plane )
 static void dither_plane_##pitch( pixel *dst, int dst_stride, uint16_t *src, int src_stride, \
                                   int width, int height, int16_t *errors ) \
 { \
-    const int lshift = 16-X264_BIT_DEPTH; \
-    const int rshift = 16-X264_BIT_DEPTH+2; \
-    const int half = 1 << (16-X264_BIT_DEPTH+1); \
-    const int pixel_max = (1 << X264_BIT_DEPTH)-1; \
+    const int lshift = 16-BIT_DEPTH; \
+    const int rshift = 16-BIT_DEPTH+2; \
+    const int half = 1 << (16-BIT_DEPTH+1); \
+    const int pixel_max = (1 << BIT_DEPTH)-1; \
     memset( errors, 0, (width+1) * sizeof(int16_t) ); \
     for( int y = 0; y < height; y++, src += src_stride, dst += dst_stride ) \
     { \
@@ -137,7 +145,7 @@ static void dither_image( cli_image_t *out, cli_image_t *img, int16_t *error_buf
 static void scale_image( cli_image_t *output, cli_image_t *img )
 {
     int csp_mask = img->csp & X264_CSP_MASK;
-    const int shift = X264_BIT_DEPTH - 8;
+    const int shift = BIT_DEPTH - 8;
     for( int i = 0; i < img->planes; i++ )
     {
         uint8_t *src = img->plane[i];
@@ -217,7 +225,7 @@ static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info,
             ret = 1;
     }
 
-    FAIL_IF_ERROR( bit_depth != X264_BIT_DEPTH, "this build supports only bit depth %d\n", X264_BIT_DEPTH );
+    FAIL_IF_ERROR( bit_depth != BIT_DEPTH, "this filter supports only bit depth %d\n", BIT_DEPTH );
     FAIL_IF_ERROR( ret, "unsupported bit depth conversion.\n" );
 
     /* only add the filter to the chain if it's needed */
index 0b9a629f4129314b7c6749af4f2198cb3cd090bb..09454354050f0d06d5d9aa9f52ebd71ead1937bd 100644 (file)
@@ -24,6 +24,7 @@
  *****************************************************************************/
 
 #include "internal.h"
+
 #define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, "x264", __VA_ARGS__ )
 
 void x264_cli_plane_copy( uint8_t *dst, int i_dst, uint8_t *src, int i_src, int w, int h )
index 2bdc167d2b7e96be8f4fe92f790dd9cfa2bce0db..cf5f1bf96378037cd153c64a103c34e277366876 100644 (file)
@@ -25,6 +25,7 @@
 
 #ifndef X264_FILTER_VIDEO_INTERNAL_H
 #define X264_FILTER_VIDEO_INTERNAL_H
+
 #include "video.h"
 
 void x264_cli_plane_copy( uint8_t *dst, int i_dst, uint8_t *src, int i_src, int w, int h );
index 51e776910f277ad038f3f3d0322428b434723e91..95c8ec8853278c9b896f3d6f25776db1d7f199df 100644 (file)
@@ -24,6 +24,7 @@
  *****************************************************************************/
 
 #include "video.h"
+
 #define NAME "resize"
 #define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, NAME, __VA_ARGS__ )
 
index f5b6750ef0bf8762471f4c7ee88722d13f9fe4b6..4fb5973ed44c66179ba47612e8ff881b7b1e3341 100644 (file)
@@ -24,6 +24,7 @@
  *****************************************************************************/
 
 #include "video.h"
+
 #define NAME "select_every"
 #define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, NAME, __VA_ARGS__ )
 
@@ -95,7 +96,9 @@ static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info, x2
          if( max_rewind == h->step_size )
              break;
     }
-    if( x264_init_vid_filter( "cache", handle, filter, info, param, (void*)max_rewind ) )
+    char name[20];
+    sprintf( name, "cache_%d", param->i_bitdepth );
+    if( x264_init_vid_filter( name, handle, filter, info, param, (void*)max_rewind ) )
         return -1;
 
     /* done initing, overwrite properties */
index 799eddf71a9570e1a5b51336fb7a1b07b7b8aa19..ace48140265f65e2e2a6619172d1a3283bcd6fd8 100644 (file)
@@ -46,12 +46,18 @@ void x264_register_vid_filters( void )
 {
     extern cli_vid_filter_t source_filter;
     first_filter = &source_filter;
-    REGISTER_VFILTER( cache );
+#if HAVE_BITDEPTH8
+    REGISTER_VFILTER( cache_8 );
+    REGISTER_VFILTER( depth_8 );
+#endif
+#if HAVE_BITDEPTH10
+    REGISTER_VFILTER( cache_10 );
+    REGISTER_VFILTER( depth_10 );
+#endif
     REGISTER_VFILTER( crop );
     REGISTER_VFILTER( fix_vfr_pts );
     REGISTER_VFILTER( resize );
     REGISTER_VFILTER( select_every );
-    REGISTER_VFILTER( depth );
 #if HAVE_GPL
 #endif
 }
index fb43e4108375f82184300ee8b5f0cae0d8a482e8..da3b49b6865bfc32345628f5003a99cc0232d7ae 100644 (file)
@@ -25,6 +25,7 @@
  *****************************************************************************/
 
 #include "input.h"
+
 #if USE_AVXSYNTH
 #include <dlfcn.h>
 #if SYS_MACOSX
@@ -39,7 +40,6 @@
 #define avs_close FreeLibrary
 #define avs_address GetProcAddress
 #endif
-#define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, "avs", __VA_ARGS__ )
 
 #define AVSC_NO_DECLSPEC
 #undef EXTERN_C
@@ -50,6 +50,8 @@
 #endif
 #define AVSC_DECLARE_FUNC(name) name##_func name
 
+#define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, "avs", __VA_ARGS__ )
+
 /* AVS uses a versioned interface to control backwards compatibility */
 /* YV12 support is required, which was added in 2.5 */
 #define AVS_INTERFACE_25 2
index 8da67af66e1946604c9d063955a38c78eeb2fd58..86f5cb67058e3d3f7f51c191473d5b57eb71314d 100644 (file)
 
 #include "input.h"
 #include <ffms.h>
-#define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, "ffms", __VA_ARGS__ )
 
 #undef DECLARE_ALIGNED
 #include <libavcodec/avcodec.h>
 #include <libswscale/swscale.h>
 
+#define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, "ffms", __VA_ARGS__ )
+
 #define PROGRESS_LENGTH 36
 
 typedef struct
index a66752deae8c754e6236284435f811778f8a3624..3b33be4a054c93f5d67df4cdb9e8f817300b0764 100644 (file)
@@ -102,7 +102,8 @@ typedef struct
 extern const cli_input_t raw_input;
 extern const cli_input_t y4m_input;
 extern const cli_input_t avs_input;
-extern const cli_input_t thread_input;
+extern const cli_input_t thread_8_input;
+extern const cli_input_t thread_10_input;
 extern const cli_input_t lavf_input;
 extern const cli_input_t ffms_input;
 extern const cli_input_t timecode_input;
index c0024a5eb9580109b4077f796e19c7cb1a458b2b..063331df304559e5e1214654230b797cbed76de6 100644 (file)
  *****************************************************************************/
 
 #include "input.h"
-#define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, "lavf", __VA_ARGS__ )
+
 #undef DECLARE_ALIGNED
 #include <libavformat/avformat.h>
 #include <libavutil/mem.h>
 #include <libavutil/pixdesc.h>
 #include <libavutil/dict.h>
 
+#define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, "lavf", __VA_ARGS__ )
+
 typedef struct
 {
     AVFormatContext *lavf;
index 1f2e73e5b4cd3637346e8cd99a42af16d0376b9c..5d48705635a09239fb98211e5c41a2c70739fed2 100644 (file)
@@ -26,6 +26,7 @@
  *****************************************************************************/
 
 #include "input.h"
+
 #define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, "raw", __VA_ARGS__ )
 
 typedef struct
index 3d83bfad0834ef9ec70ff89972796469710082e8..34a247f192a48c370dd7f78184b152c6916b83b3 100644 (file)
@@ -25,6 +25,9 @@
  *****************************************************************************/
 
 #include "input.h"
+#include "common/common.h"
+
+#define thread_input x264_glue3(thread, BIT_DEPTH, input)
 
 typedef struct
 {
index 25f924c717eaa790d1c20fc3ca69c3c29952dada..23a295b477838177211ee3877b9c3fca9cbcef68 100644 (file)
@@ -24,6 +24,7 @@
  *****************************************************************************/
 
 #include "input.h"
+
 #define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, "timecode", __VA_ARGS__ )
 
 typedef struct
index 09dbb139fd9e1fbaee1604ad7553956eda58b4c8..7852e5884fd75e93021553aaeb3e1bede119d309 100644 (file)
@@ -25,6 +25,7 @@
  *****************************************************************************/
 
 #include "input.h"
+
 #define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, "y4m", __VA_ARGS__ )
 
 typedef struct
index e858abed6b2d36f21c6164b49e34ccd90799f4f2..74d9819a42a93b24aec3f7500ba1c62a753a88c2 100644 (file)
@@ -149,7 +149,7 @@ function checkasm_call, export=1
     mov         w9,  #0
     str         w9,  [x2]
     movrel      x0, error_message
-    bl          X(puts)
+    bl          EXT(puts)
 0:
     ldp         x0,  x1,  [sp], #16
     ldp         d14, d15, [sp], #16
index c7be467109c95f555e7bcedfb40df3e50ef770db..ec1a6689f7dd324da8c71047009795c2e040e99a 100644 (file)
@@ -128,11 +128,7 @@ function checkasm_call_\variant
     mov         r12, #0
     str         r12, [r2]
     movrel      r0, error_message
-#ifdef PREFIX
-    blx         _puts
-#else
-    blx         puts
-#endif
+    blx         EXT(puts)
 0:
     pop         {r0, r1}
 .ifc \variant, neon
index a131b58ca1e9bd790b17890042cb8d72801a66e3..5b1d6f7efcf0d5102da7fe4ba79b633edbbaa467 100644 (file)
@@ -27,7 +27,6 @@
 
 #include <ctype.h>
 #include "common/common.h"
-#include "common/cpu.h"
 #include "encoder/macroblock.h"
 
 #ifdef _WIN32
diff --git a/x264.c b/x264.c
index 93f2d5813b2046984dbbfa47387bbb4476dfd40d..a48c17e52bfb82e60851cae526ac61b7990a51c3 100644 (file)
--- a/x264.c
+++ b/x264.c
 
 #include <signal.h>
 #include <getopt.h>
-#include "common/common.h"
 #include "x264cli.h"
 #include "input/input.h"
 #include "output/output.h"
 #include "filters/filters.h"
 
+#define QP_MAX_SPEC (51+6*2)
+#define QP_MAX (QP_MAX_SPEC+18)
+
 #define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, "x264", __VA_ARGS__ )
 
 #if HAVE_LAVF
@@ -331,8 +333,8 @@ static void print_version_info( void )
 #else
     printf( "using an unknown compiler\n" );
 #endif
-    printf( "x264 configuration: --bit-depth=%d --chroma-format=%s\n", X264_BIT_DEPTH, chroma_format_names[X264_CHROMA_FORMAT] );
-    printf( "libx264 configuration: --bit-depth=%d --chroma-format=%s\n", x264_bit_depth, chroma_format_names[x264_chroma_format] );
+    printf( "x264 configuration: --chroma-format=%s\n", chroma_format_names[X264_CHROMA_FORMAT] );
+    printf( "libx264 configuration: --chroma-format=%s\n", chroma_format_names[x264_chroma_format] );
     printf( "x264 license: " );
 #if HAVE_GPL
     printf( "GPL version 2 or later\n" );
@@ -483,7 +485,7 @@ static void help( x264_param_t *defaults, int longhelp )
         " .mkv -> Matroska\n"
         " .flv -> Flash Video\n"
         " .mp4 -> MP4 if compiled with GPAC or L-SMASH support (%s)\n"
-        "Output bit depth: %d (configured at compile time)\n"
+        "Output bit depth: %s\n."
         "\n"
         "Options:\n"
         "\n"
@@ -514,7 +516,15 @@ static void help( x264_param_t *defaults, int longhelp )
 #else
         "no",
 #endif
-        x264_bit_depth
+#if HAVE_BITDEPTH8 && HAVE_BITDEPTH10
+        "8/10"
+#elif HAVE_BITDEPTH8
+        "8"
+#elif HAVE_BITDEPTH10
+        "10"
+#else
+        "none"
+#endif
       );
     H0( "Example usage:\n" );
     H0( "\n" );
@@ -540,7 +550,6 @@ static void help( x264_param_t *defaults, int longhelp )
         "                                  Overrides all settings.\n" );
     H2(
 #if X264_CHROMA_FORMAT <= X264_CSP_I420
-#if X264_BIT_DEPTH==8
         "                                  - baseline:\n"
         "                                    --no-8x8dct --bframes 0 --no-cabac\n"
         "                                    --cqm flat --weightp 0\n"
@@ -551,7 +560,6 @@ static void help( x264_param_t *defaults, int longhelp )
         "                                    No lossless.\n"
         "                                  - high:\n"
         "                                    No lossless.\n"
-#endif
         "                                  - high10:\n"
         "                                    No lossless.\n"
         "                                    Support for bit depth 8-10.\n"
@@ -568,10 +576,7 @@ static void help( x264_param_t *defaults, int longhelp )
         else H0(
         "                                  - "
 #if X264_CHROMA_FORMAT <= X264_CSP_I420
-#if X264_BIT_DEPTH==8
-        "baseline,main,high,"
-#endif
-        "high10,"
+        "baseline,main,high,high10,"
 #endif
 #if X264_CHROMA_FORMAT <= X264_CSP_I422
         "high422,"
@@ -884,6 +889,7 @@ static void help( x264_param_t *defaults, int longhelp )
     H1( "      --output-csp <string>   Specify output colorspace [\"%s\"]\n"
         "                                  - %s\n", output_csp_names[0], stringify_names( buf, output_csp_names ) );
     H1( "      --input-depth <integer> Specify input bit depth for raw input\n" );
+    H1( "      --output-depth <integer> Specify output bit depth\n" );
     H1( "      --input-range <string>  Specify input color range [\"%s\"]\n"
         "                                  - %s\n", range_names[0], stringify_names( buf, range_names ) );
     H1( "      --input-res <intxint>   Specify input resolution (width x height)\n" );
@@ -972,6 +978,7 @@ typedef enum
     OPT_INPUT_RES,
     OPT_INPUT_CSP,
     OPT_INPUT_DEPTH,
+    OPT_OUTPUT_DEPTH,
     OPT_DTS_COMPRESSION,
     OPT_OUTPUT_CSP,
     OPT_INPUT_RANGE,
@@ -1139,6 +1146,7 @@ static struct option long_options[] =
     { "input-res",   required_argument, NULL, OPT_INPUT_RES },
     { "input-csp",   required_argument, NULL, OPT_INPUT_CSP },
     { "input-depth", required_argument, NULL, OPT_INPUT_DEPTH },
+    { "output-depth", required_argument, NULL, OPT_OUTPUT_DEPTH },
     { "dts-compress",      no_argument, NULL, OPT_DTS_COMPRESSION },
     { "output-csp",  required_argument, NULL, OPT_OUTPUT_CSP },
     { "input-range", required_argument, NULL, OPT_INPUT_RANGE },
@@ -1314,10 +1322,11 @@ static int init_vid_filters( char *sequence, hnd_t *handle, video_info_t *info,
     if( x264_init_vid_filter( "resize", handle, &filter, info, param, NULL ) )
         return -1;
 
-    char args[20];
-    sprintf( args, "bit_depth=%d", x264_bit_depth );
+    char args[20], name[20];
+    sprintf( args, "bit_depth=%d", param->i_bitdepth );
+    sprintf( name, "depth_%d", param->i_bitdepth );
 
-    if( x264_init_vid_filter( "depth", handle, &filter, info, param, args ) )
+    if( x264_init_vid_filter( name, handle, &filter, info, param, args ) )
         return -1;
 
     return 0;
@@ -1516,6 +1525,9 @@ static int parse( int argc, char **argv, x264_param_t *param, cli_opt_t *opt )
             case OPT_INPUT_DEPTH:
                 input_opt.bit_depth = atoi( optarg );
                 break;
+            case OPT_OUTPUT_DEPTH:
+                param->i_bitdepth = atoi( optarg );
+                break;
             case OPT_DTS_COMPRESSION:
                 output_opt.use_dts_compress = 1;
                 break;
@@ -1627,15 +1639,23 @@ generic_option:
 
     /* init threaded input while the information about the input video is unaltered by filtering */
 #if HAVE_THREAD
-    if( info.thread_safe && (b_thread_input || param->i_threads > 1
+    const cli_input_t *thread_input;
+    if( HAVE_BITDEPTH8 && param->i_bitdepth == 8 )
+        thread_input = &thread_8_input;
+    else if( HAVE_BITDEPTH10 && param->i_bitdepth == 10 )
+        thread_input = &thread_10_input;
+    else
+        thread_input = NULL;
+
+    if( thread_input && info.thread_safe && (b_thread_input || param->i_threads > 1
         || (param->i_threads == X264_THREADS_AUTO && x264_cpu_num_processors() > 1)) )
     {
-        if( thread_input.open_file( NULL, &opt->hin, &info, NULL ) )
+        if( thread_input->open_file( NULL, &opt->hin, &info, NULL ) )
         {
             fprintf( stderr, "x264 [error]: threaded input failed\n" );
             return -1;
         }
-        cli_input = thread_input;
+        cli_input = *thread_input;
     }
 #endif
 
diff --git a/x264.h b/x264.h
index 039a618b5c6403cfefdf44206c851f2e0fc61f71..9f1057db48e53b3970e68af7e41df5df71b34a64 100644 (file)
--- a/x264.h
+++ b/x264.h
@@ -45,7 +45,7 @@ extern "C" {
 
 #include "x264_config.h"
 
-#define X264_BUILD 152
+#define X264_BUILD 153
 
 /* Application developers planning to link against a shared library version of
  * libx264 from a Microsoft Visual Studio or similar development environment
@@ -292,6 +292,7 @@ typedef struct x264_param_t
     int         i_width;
     int         i_height;
     int         i_csp;         /* CSP of encoded bitstream */
+    int         i_bitdepth;
     int         i_level_idc;
     int         i_frame_total; /* number of frames to encode if known, else 0 */
 
@@ -670,15 +671,6 @@ int     x264_param_apply_profile( x264_param_t *, const char *profile );
  * Picture structures and functions
  ****************************************************************************/
 
-/* x264_bit_depth:
- *      Specifies the number of bits per pixel that x264 uses. This is also the
- *      bit depth that x264 encodes in. If this value is > 8, x264 will read
- *      two bytes of input data for each pixel sample, and expect the upper
- *      (16-x264_bit_depth) bits to be zero.
- *      Note: The flag X264_CSP_HIGH_DEPTH must be used to specify the
- *      colorspace depth as well. */
-X264_API extern const int x264_bit_depth;
-
 /* x264_chroma_format:
  *      Specifies the chroma formats that x264 supports encoding. When this
  *      value is non-zero, then it represents a X264_CSP_* that is the only
@@ -913,10 +905,10 @@ void    x264_encoder_close( x264_t * );
  *      return the number of currently delayed (buffered) frames
  *      this should be used at the end of the stream, to know when you have all the encoded frames. */
 int     x264_encoder_delayed_frames( x264_t * );
-/* x264_encoder_maximum_delayed_frames( x264_t *h ):
+/* x264_encoder_maximum_delayed_frames( x264_t * ):
  *      return the maximum number of delayed (buffered) frames that can occur with the current
  *      parameters. */
-int     x264_encoder_maximum_delayed_frames( x264_t *h );
+int     x264_encoder_maximum_delayed_frames( x264_t * );
 /* x264_encoder_intra_refresh:
  *      If an intra refresh is not in progress, begin one with the next P-frame.
  *      If an intra refresh is in progress, begin one as soon as the current one finishes.
index 9b5d31e369fb64b0a29c2d3da5db6d53a0764d3d..dbc9a5a27e981c0e79a9c0feb98dc980580968ed 100644 (file)
--- a/x264cli.h
+++ b/x264cli.h
@@ -27,7 +27,7 @@
 #ifndef X264_CLI_H
 #define X264_CLI_H
 
-#include "common/common.h"
+#include "common/base.h"
 
 /* In microseconds */
 #define UPDATE_INTERVAL 250000
index cce96fe8922c56455088f1621a088f15ad9d875c..4325c33ffda585daaaa280bad5787cab7ce81cfa 100644 (file)
--- a/x264dll.c
+++ b/x264dll.c
@@ -23,7 +23,7 @@
  * For more information, contact us at licensing@x264.com.
  *****************************************************************************/
 
-#include "common/common.h"
+#include "common/base.h"
 #include <windows.h>
 
 /* Callback for our DLL so we can initialize pthread */