]> git.sesse.net Git - x264/blob - Makefile
CABAC trellis opts part 4: x86_64 asm
[x264] / Makefile
1 # Makefile
2
3 include config.mak
4
5 vpath %.c $(SRCPATH)
6 vpath %.h $(SRCPATH)
7 vpath %.S $(SRCPATH)
8 vpath %.asm $(SRCPATH)
9
10 all: default
11
12 SRCS = common/mc.c common/predict.c common/pixel.c common/macroblock.c \
13        common/frame.c common/dct.c common/cpu.c common/cabac.c \
14        common/common.c common/osdep.c common/rectangle.c \
15        common/set.c common/quant.c common/deblock.c common/vlc.c \
16        common/mvpred.c common/bitstream.c \
17        encoder/analyse.c encoder/me.c encoder/ratecontrol.c \
18        encoder/set.c encoder/macroblock.c encoder/cabac.c \
19        encoder/cavlc.c encoder/encoder.c encoder/lookahead.c
20
21 SRCCLI = x264.c input/input.c input/timecode.c input/raw.c input/y4m.c \
22          output/raw.c output/matroska.c output/matroska_ebml.c \
23          output/flv.c output/flv_bytestream.c filters/filters.c \
24          filters/video/video.c filters/video/source.c filters/video/internal.c \
25          filters/video/resize.c filters/video/cache.c filters/video/fix_vfr_pts.c \
26          filters/video/select_every.c filters/video/crop.c filters/video/depth.c
27
28 SRCSO =
29
30 OBJCHK = tools/checkasm.o
31
32 CONFIG := $(shell cat config.h)
33
34 # GPL-only files
35 ifneq ($(findstring HAVE_GPL 1, $(CONFIG)),)
36 SRCCLI +=
37 endif
38
39 # Optional module sources
40 ifneq ($(findstring HAVE_AVS 1, $(CONFIG)),)
41 SRCCLI += input/avs.c
42 endif
43
44 ifneq ($(findstring HAVE_THREAD 1, $(CONFIG)),)
45 SRCCLI += input/thread.c
46 SRCS   += common/threadpool.c
47 endif
48
49 ifneq ($(findstring HAVE_WIN32THREAD 1, $(CONFIG)),)
50 SRCS += common/win32thread.c
51 endif
52
53 ifneq ($(findstring HAVE_LAVF 1, $(CONFIG)),)
54 SRCCLI += input/lavf.c
55 endif
56
57 ifneq ($(findstring HAVE_FFMS 1, $(CONFIG)),)
58 SRCCLI += input/ffms.c
59 endif
60
61 ifneq ($(findstring HAVE_GPAC 1, $(CONFIG)),)
62 SRCCLI += output/mp4.c
63 endif
64
65 # Visualization sources
66 ifneq ($(findstring HAVE_VISUALIZE 1, $(CONFIG)),)
67 SRCS   += common/visualize.c common/display-x11.c
68 endif
69
70 # MMX/SSE optims
71 ifneq ($(AS),)
72 X86SRC0 = const-a.asm cabac-a.asm dct-a.asm deblock-a.asm mc-a.asm \
73           mc-a2.asm pixel-a.asm predict-a.asm quant-a.asm \
74           cpu-a.asm dct-32.asm bitstream-a.asm
75 ifneq ($(findstring HIGH_BIT_DEPTH, $(CONFIG)),)
76 X86SRC0 += sad16-a.asm
77 else
78 X86SRC0 += sad-a.asm
79 endif
80 X86SRC = $(X86SRC0:%=common/x86/%)
81
82 ifeq ($(ARCH),X86)
83 ARCH_X86 = yes
84 ASMSRC   = $(X86SRC) common/x86/pixel-32.asm
85 endif
86
87 ifeq ($(ARCH),X86_64)
88 ARCH_X86 = yes
89 ASMSRC   = $(X86SRC:-32.asm=-64.asm) common/x86/trellis-64.asm
90 ASFLAGS += -DARCH_X86_64
91 endif
92
93 ifdef ARCH_X86
94 ASFLAGS += -I$(SRCPATH)/common/x86/
95 SRCS   += common/x86/mc-c.c common/x86/predict-c.c
96 OBJASM  = $(ASMSRC:%.asm=%.o)
97 $(OBJASM): common/x86/x86inc.asm common/x86/x86util.asm
98 OBJCHK += tools/checkasm-a.o
99 endif
100 endif
101
102 # AltiVec optims
103 ifeq ($(ARCH),PPC)
104 ifneq ($(AS),)
105 SRCS += common/ppc/mc.c common/ppc/pixel.c common/ppc/dct.c \
106         common/ppc/quant.c common/ppc/deblock.c \
107         common/ppc/predict.c
108 endif
109 endif
110
111 # NEON optims
112 ifeq ($(ARCH),ARM)
113 ifneq ($(AS),)
114 ASMSRC += common/arm/cpu-a.S common/arm/pixel-a.S common/arm/mc-a.S \
115           common/arm/dct-a.S common/arm/quant-a.S common/arm/deblock-a.S \
116           common/arm/predict-a.S
117 SRCS   += common/arm/mc-c.c common/arm/predict-c.c
118 OBJASM  = $(ASMSRC:%.S=%.o)
119 endif
120 endif
121
122 # VIS optims
123 ifeq ($(ARCH),UltraSPARC)
124 ifeq ($(findstring HIGH_BIT_DEPTH, $(CONFIG)),)
125 ASMSRC += common/sparc/pixel.asm
126 OBJASM  = $(ASMSRC:%.asm=%.o)
127 endif
128 endif
129
130 ifneq ($(HAVE_GETOPT_LONG),1)
131 SRCCLI += extras/getopt.c
132 endif
133
134 ifneq ($(SONAME),)
135 ifeq ($(SYS),WINDOWS)
136 SRCSO += x264dll.c
137 endif
138 endif
139
140 OBJS = $(SRCS:%.c=%.o)
141 OBJCLI = $(SRCCLI:%.c=%.o)
142 OBJSO = $(SRCSO:%.c=%.o)
143 DEP  = depend
144
145 .PHONY: all default fprofiled clean distclean install uninstall lib-static lib-shared cli install-lib-dev install-lib-static install-lib-shared install-cli
146
147 default: $(DEP)
148
149 cli: x264$(EXE)
150 lib-static: $(LIBX264)
151 lib-shared: $(SONAME)
152
153 $(LIBX264): .depend $(OBJS) $(OBJASM)
154         rm -f $(LIBX264)
155         $(AR)$@ $(OBJS) $(OBJASM)
156         $(if $(RANLIB), $(RANLIB) $@)
157
158 $(SONAME): .depend $(OBJS) $(OBJASM) $(OBJSO)
159         $(LD)$@ $(OBJS) $(OBJASM) $(OBJSO) $(SOFLAGS) $(LDFLAGS)
160
161 ifneq ($(EXE),)
162 .PHONY: x264 checkasm
163 x264: x264$(EXE)
164 checkasm: checkasm$(EXE)
165 endif
166
167 x264$(EXE): .depend $(OBJCLI) $(CLI_LIBX264)
168         $(LD)$@ $(OBJCLI) $(CLI_LIBX264) $(LDFLAGSCLI) $(LDFLAGS)
169
170 checkasm$(EXE): .depend $(OBJCHK) $(LIBX264)
171         $(LD)$@ $(OBJCHK) $(LIBX264) $(LDFLAGS)
172
173 $(OBJS) $(OBJASM) $(OBJSO) $(OBJCLI) $(OBJCHK): .depend
174
175 %.o: %.asm
176         $(AS) $(ASFLAGS) -o $@ $<
177         -@ $(if $(STRIP), $(STRIP) -x $@) # delete local/anonymous symbols, so they don't show up in oprofile
178
179 %.o: %.S
180         $(AS) $(ASFLAGS) -o $@ $<
181         -@ $(if $(STRIP), $(STRIP) -x $@) # delete local/anonymous symbols, so they don't show up in oprofile
182
183 .depend: config.mak
184         @rm -f .depend
185         @$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCS) $(SRCCLI) $(SRCSO)), $(CC) $(CFLAGS) $(SRC) $(DEPMT) $(SRC:$(SRCPATH)/%.c=%.o) $(DEPMM) 1>> .depend;)
186
187 config.mak:
188         ./configure
189
190 depend: .depend
191 ifneq ($(wildcard .depend),)
192 include .depend
193 endif
194
195 SRC2 = $(SRCS) $(SRCCLI)
196 # These should cover most of the important codepaths
197 OPT0 = --crf 30 -b1 -m1 -r1 --me dia --no-cabac --direct temporal --ssim --no-weightb
198 OPT1 = --crf 16 -b2 -m3 -r3 --me hex --no-8x8dct --direct spatial --no-dct-decimate -t0  --slice-max-mbs 50
199 OPT2 = --crf 26 -b4 -m5 -r2 --me hex --cqm jvt --nr 100 --psnr --no-mixed-refs --b-adapt 2 --slice-max-size 1500
200 OPT3 = --crf 18 -b3 -m9 -r5 --me umh -t1 -A all --b-pyramid normal --direct auto --no-fast-pskip --no-mbtree
201 OPT4 = --crf 22 -b3 -m7 -r4 --me esa -t2 -A all --psy-rd 1.0:1.0 --slices 4
202 OPT5 = --frames 50 --crf 24 -b3 -m10 -r3 --me tesa -t2
203 OPT6 = --frames 50 -q0 -m9 -r2 --me hex -Aall
204 OPT7 = --frames 50 -q0 -m2 -r1 --me hex --no-cabac
205
206 ifeq (,$(VIDS))
207 fprofiled:
208         @echo 'usage: make fprofiled VIDS="infile1 infile2 ..."'
209         @echo 'where infiles are anything that x264 understands,'
210         @echo 'i.e. YUV with resolution in the filename, y4m, or avisynth.'
211 else
212 fprofiled:
213         $(MAKE) clean
214         $(MAKE) x264$(EXE) CFLAGS="$(CFLAGS) $(PROF_GEN_CC)" LDFLAGS="$(LDFLAGS) $(PROF_GEN_LD)"
215         $(foreach V, $(VIDS), $(foreach I, 0 1 2 3 4 5 6 7, ./x264$(EXE) $(OPT$I) --threads 1 $(V) -o $(DEVNULL) ;))
216         rm -f $(SRC2:%.c=%.o)
217         $(MAKE) CFLAGS="$(CFLAGS) $(PROF_USE_CC)" LDFLAGS="$(LDFLAGS) $(PROF_USE_LD)"
218         rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno) *.dyn pgopti.dpi pgopti.dpi.lock
219 endif
220
221 clean:
222         rm -f $(OBJS) $(OBJASM) $(OBJCLI) $(OBJSO) $(SONAME) *.a *.lib *.exp *.pdb x264 x264.exe .depend TAGS
223         rm -f checkasm checkasm.exe $(OBJCHK)
224         rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno) *.dyn pgopti.dpi pgopti.dpi.lock
225
226 distclean: clean
227         rm -f config.mak x264_config.h config.h config.log x264.pc x264.def
228
229 install-cli: cli
230         install -d $(DESTDIR)$(bindir)
231         install x264$(EXE) $(DESTDIR)$(bindir)
232
233 install-lib-dev:
234         install -d $(DESTDIR)$(includedir)
235         install -d $(DESTDIR)$(libdir)
236         install -d $(DESTDIR)$(libdir)/pkgconfig
237         install -m 644 $(SRCPATH)/x264.h $(DESTDIR)$(includedir)
238         install -m 644 x264_config.h $(DESTDIR)$(includedir)
239         install -m 644 x264.pc $(DESTDIR)$(libdir)/pkgconfig
240
241 install-lib-static: lib-static install-lib-dev
242         install -m 644 $(LIBX264) $(DESTDIR)$(libdir)
243         $(if $(RANLIB), $(RANLIB) $(DESTDIR)$(libdir)/$(LIBX264))
244
245 install-lib-shared: lib-shared install-lib-dev
246 ifneq ($(IMPLIBNAME),)
247         install -d $(DESTDIR)$(bindir)
248         install -m 755 $(SONAME) $(DESTDIR)$(bindir)
249         install -m 644 $(IMPLIBNAME) $(DESTDIR)$(libdir)
250 else ifneq ($(SONAME),)
251         ln -f -s $(SONAME) $(DESTDIR)$(libdir)/libx264.$(SOSUFFIX)
252         install -m 755 $(SONAME) $(DESTDIR)$(libdir)
253 endif
254
255 uninstall:
256         rm -f $(DESTDIR)$(includedir)/x264.h $(DESTDIR)$(includedir)/x264_config.h $(DESTDIR)$(libdir)/libx264.a
257         rm -f $(DESTDIR)$(bindir)/x264$(EXE) $(DESTDIR)$(libdir)/pkgconfig/x264.pc
258 ifneq ($(IMPLIBNAME),)
259         rm -f $(DESTDIR)$(bindir)/$(SONAME) $(DESTDIR)$(libdir)/$(IMPLIBNAME)
260 else ifneq ($(SONAME),)
261         rm -f $(DESTDIR)$(libdir)/$(SONAME) $(DESTDIR)$(libdir)/libx264.$(SOSUFFIX)
262 endif
263
264 etags: TAGS
265
266 TAGS:
267         etags $(SRCS)