revert openexr-2.4.0, breaks most builds, req cmake past baseline, bad configure...
[goodguy/cinelerra.git] / cinelerra-5.1 / thirdparty / src / dav1d-0.4.0.patch1
1 diff -uN dav1d-0.4.0.orig/Makefile dav1d-0.4.0/Makefile
2 --- dav1d-0.4.0.orig/Makefile   1969-12-31 17:00:00.000000000 -0700
3 +++ dav1d-0.4.0/Makefile        2019-09-05 16:38:01.820636946 -0600
4 @@ -0,0 +1,358 @@
5 +
6 +_ARCH := $(shell uname -m)
7 +ARCH_I32 := $(shell expr "x$(_ARCH)" : 'xi[346]86.*')
8 +ARCH_X64 := $(shell expr "x$(_ARCH)" : 'x..._64*')
9 +
10 +ifneq ($(ARCH_I32),0)
11 +ASM_ARCH := elf32
12 +ARCH_X86_32 := 1
13 +ARCH_X86_64 := 0
14 +endif
15 +ifneq ($(ARCH_X64),0)
16 +ASM_ARCH := elf64
17 +ARCH_X86_32 := 0
18 +ARCH_X86_64 := 1
19 +endif
20 +
21 +BUILD=build
22 +DESTDIR=/
23 +PREFIX=usr/local
24 +LIBDIR=$(PREFIX)/lib
25 +INCDIR=$(PREFIX)/include
26 +# make Q="" for verbose
27 +Q?=@echo == $@; 
28 +OBJDIR?=$(BUILD)/static
29 +NASM_BLD=$(OBJDIR)/nasm
30 +ENTRY_BLD=$(OBJDIR)/entry
31 +SRC_BLD=$(OBJDIR)/src
32 +BIT8_BLD=$(OBJDIR)/bits8
33 +BIT16_BLD=$(OBJDIR)/bits16
34 +TOOLS_BLD=$(BUILD)/tools
35 +TESTS_BLD=$(BUILD)/tests
36 +
37 +STATIC_LIB=$(BUILD)/src/libdav1d.a
38 +SHARED_LIB=$(BUILD)/src/libdav1d.so
39 +DEFS= -DNDEBUG -D_FILE_OFFSET_BITS=64 -D_POSIX_C_SOURCE=200112L
40 +FUZZ= -DDAV1D_MT_FUZZING
41 +
42 +BLD_INCL= $(DEFS) -I. -Isrc -Iinclude/dav1d -Iinclude \
43 +       -I$(BUILD) -I$(BUILD)/include -I$(BUILD)/include/dav1d
44 +TOOLS_INCL= $(DEFS) -Itools -I. -I$(BUILD) -I$(BUILD)/tools \
45 +       -Iinclude -Iinclude/dav1d -I$(BUILD)/include/dav1d \
46 +       -I$(BUILD)/include -I/usr/include/SDL2
47 +
48 +NP?=.NOTPARALLEL:
49 +$(NP)
50 +MAKE_P:=$(MAKE) -j NP=""
51 +
52 +all: meson_data
53 +       $(MAKE_P) $(STATIC_LIB) OBJDIR=$(BUILD)/static
54 +       $(MAKE_P) $(SHARED_LIB) OBJDIR=$(BUILD)/shared
55 +# req SDL
56 +#      $(MAKE_P) $(TOOLS) OBJDIR=$(BUILD)/static
57 +#      $(MAKE_P) $(TESTS) OBJDIR=$(BUILD)/static
58 +
59 +CC_DEFS=\
60 +       -DNDEBUG \
61 +       -D_FILE_OFFSET_BITS=64 \
62 +       -D_POSIX_C_SOURCE=200112L \
63 +
64 +CC_OPTS=\
65 +       -pipe \
66 +       -Wall \
67 +       -Winvalid-pch \
68 +       -Wextra \
69 +       -std=c99 \
70 +       -O3 \
71 +       -fvisibility=hidden \
72 +       -Wundef \
73 +       -Werror=vla \
74 +       -Wno-maybe-uninitialized \
75 +       -Wno-missing-field-initializers \
76 +       -Wno-unused-parameter \
77 +       -Werror=missing-prototypes \
78 +       -fomit-frame-pointer \
79 +       -ffast-math \
80 +       -fPIC \
81 +       -mpreferred-stack-boundary=5 \
82 +       -MD -MQ $@ -MF $@.d \
83 +
84 +SHA_OPTS=\
85 +       -Wl,--no-undefined \
86 +       -Wl,--as-needed \
87 +       -Wl,-O1 \
88 +       -shared \
89 +       -fPIC \
90 +       -Wl,--start-group \
91 +       -Wl,-soname,libdav1d.so.2 \
92 +       -Wl,--end-group \
93 +       -pthread \
94 +
95 +CC_CC=$(Q)cc $(CC_OPTS) $(CFLAGS)
96 +NASM=$(Q)/usr/bin/nasm
97 +any=$(foreach i,$(2),$(1)/$(i))
98 +
99 +# nasm
100 +NASM_OBJS=$(call any,$(NASM_BLD), \
101 +       cdef.obj \
102 +       cdef_sse.obj \
103 +       cpuid.obj \
104 +       ipred.obj \
105 +       ipred_ssse3.obj \
106 +       itx.obj \
107 +       itx_ssse3.obj \
108 +       loopfilter.obj \
109 +       looprestoration.obj \
110 +       looprestoration_ssse3.obj \
111 +       mc.obj \
112 +       mc_ssse3.obj \
113 +       msac.obj)
114 +$(NASM_BLD)/%.obj: src/x86/%.asm
115 +       $(NASM) -f $(ASM_ARCH) \
116 +               -I src/ -I $(BUILD)/ -MQ $@ -MF $@.ndep \
117 +               $< -o $@
118 +
119 +# entry
120 +ENTRY_OBJS=$(call any,$(ENTRY_BLD), \
121 +       lib.c.o \
122 +       thread_task.c.o)
123 +$(ENTRY_BLD)/%.c.o: src/%.c
124 +       $(CC_CC) -Iinclude -Ibuild/include/dav1d -Isrc/entry $(BLD_INCL) \
125 +               -mincoming-stack-boundary=4 -o $@ -c $<
126 +
127 +# src
128 +SRC_OBJS=$(call any,$(SRC_BLD), \
129 +       cdf.o \
130 +       cpu.o \
131 +       data.o \
132 +       decode.o \
133 +       dequant_tables.o \
134 +       getbits.o \
135 +       intra_edge.o \
136 +       lf_mask.o \
137 +       log.o \
138 +       msac.o \
139 +       obu.o \
140 +       picture.o \
141 +       qm.o \
142 +       ref.o \
143 +       ref_mvs.o \
144 +       scan.o \
145 +       tables.o \
146 +       warpmv.o \
147 +       wedge.o \
148 +       x86/cpu.c.o)
149 +$(SRC_BLD)/%.o: src/%.c
150 +       $(CC_CC) $(BLD_INCL) -pthread -o $@ -c $<
151 +$(SRC_BLD)/x86/%.c.o: src/x86/%.c
152 +       $(CC_CC) $(BLD_INCL) -o $@ -c $<
153 +
154 +# bits
155 +BITS_OBJS= \
156 +       cdef_tmpl.o \
157 +       cdef_apply_tmpl.o \
158 +       film_grain_tmpl.o \
159 +       ipred_tmpl.o \
160 +       ipred_prepare_tmpl.o \
161 +       itx_tmpl.o \
162 +       lf_apply_tmpl.o \
163 +       loopfilter_tmpl.o \
164 +       looprestoration_tmpl.o \
165 +       lr_apply_tmpl.o \
166 +       mc_tmpl.o \
167 +       recon_tmpl.o \
168 +       x86/cdef_init_tmpl.c.o \
169 +       x86/ipred_init_tmpl.c.o \
170 +       x86/itx_init_tmpl.c.o \
171 +       x86/loopfilter_init_tmpl.c.o \
172 +       x86/looprestoration_init_tmpl.c.o \
173 +       x86/mc_init_tmpl.c.o \
174 +
175 +BIT8_OBJS=$(call any,$(BIT8_BLD),$(BITS_OBJS))
176 +$(BIT8_BLD)/x86/%.c.o: src/x86/%.c
177 +       $(CC_CC) $(BLD_INCL) -DBITDEPTH=8 -o $@ -c $<
178 +$(BIT8_BLD)/%.o: src/%.c
179 +       $(CC_CC) $(BLD_INCL) -DBITDEPTH=8 -o $@ -c $<
180 +
181 +BIT16_OBJS=$(call any,$(BIT16_BLD),$(BITS_OBJS))
182 +$(BIT16_BLD)/x86/%.c.o: src/x86/%.c
183 +       $(CC_CC) $(BLD_INCL) -DBITDEPTH=16 -o $@ -c $<
184 +$(BIT16_BLD)/%.o: src/%.c
185 +       $(CC_CC) $(BLD_INCL) -DBITDEPTH=16 -o $@ -c $<
186 +
187 +$(BUILD)/config.h:
188 +       echo  > $@ "#pragma once"
189 +       echo >> $@ "#define ARCH_AARCH64 0"
190 +       echo >> $@ "#define ARCH_ARM 0"
191 +       echo >> $@ "#define ARCH_PPC64LE 0"
192 +       echo >> $@ "#define ARCH_X86 1"
193 +       echo >> $@ "#define ARCH_X86_32 $(ARCH_X86_32)"
194 +       echo >> $@ "#define ARCH_X86_64 $(ARCH_X86_64)"
195 +       echo >> $@ "#define CONFIG_16BPC 1"
196 +       echo >> $@ "#define CONFIG_8BPC 1"
197 +       echo >> $@ "#define CONFIG_LOG 1"
198 +       echo >> $@ "#define ENDIANNESS_BIG 0"
199 +       echo >> $@ "#define HAVE_ASM 1"
200 +       echo >> $@ "#define HAVE_POSIX_MEMALIGN 1"
201 +       echo >> $@ "#define HAVE_UNISTD_H 1"
202 +       echo >> $@ "#define STACK_ALIGNMENT 32"
203 +
204 +$(BUILD)/config.asm:
205 +       echo  > $@ "%define ARCH_X86_32 $(ARCH_X86_32)"
206 +       echo >> $@ "%define ARCH_X86_64 $(ARCH_X86_64)"
207 +       echo >> $@ "%define PIC 1"
208 +       echo >> $@ "%define STACK_ALIGNMENT 32"
209 +
210 +$(BUILD)/include/vcs_version.h:
211 +       mkdir -p $(BUILD)/include
212 +       echo  > $@ "#define DAV1D_VERSION \"0.4.0\""
213 +
214 +$(BUILD)/include/dav1d/version.h:
215 +       mkdir -p $(BUILD)/include/dav1d
216 +       echo  > $@ "#ifndef DAV1D_VERSION_H"
217 +       echo >> $@ "#define DAV1D_VERSION_H"
218 +       echo >> $@ "#define DAV1D_API_VERSION_MAJOR 2"
219 +       echo >> $@ "#define DAV1D_API_VERSION_MINOR 0"
220 +       echo >> $@ "#define DAV1D_API_VERSION_PATCH 0"
221 +       echo >> $@ "#endif /* DAV1D_VERSION_H */"
222 +
223 +$(TOOLS_BLD)/cli_config.h:
224 +       mkdir -p $(TOOLS_BLD)
225 +       echo  > $@ "#pragma once"
226 +       echo >> $@ "#define HAVE_CLOCK_GETTIME 1"
227 +
228 +.PHONY: meson_data
229 +meson_data:
230 +       make meson_dirs OBJDIR=$(BUILD)/static
231 +       make meson_dirs OBJDIR=$(BUILD)/shared
232 +       ln -sf ./include/compat/gcc/stdatomic.h .
233 +
234 +.PHONY: meson_dirs
235 +meson_dirs: $(OBJDIR) \
236 +       $(BUILD)/config.h $(BUILD)/config.asm \
237 +       $(BUILD)/include/vcs_version.h \
238 +       $(BUILD)/include/dav1d/version.h \
239 +       $(TOOLS_BLD)/cli_config.h \
240 +
241 +LIB_OBJS=$(ENTRY_OBJS) $(NASM_OBJS) $(SRC_OBJS) $(BIT8_OBJS) $(BIT16_OBJS)
242 +
243 +$(STATIC_LIB): DIR?=static
244 +$(STATIC_LIB): $(LIB_OBJS)
245 +       rm -f $@
246 +       gcc-ar csrD $@ $(LIB_OBJS)
247 +
248 +$(SHARED_LIB): DIR?=shared
249 +$(SHARED_LIB): $(LIB_OBJS)
250 +       rm -f $@
251 +       cc -o $@ $(LIB_OBJS) $(SHA_OPTS)
252 +
253 +# tools
254 +DAV1D_OBJS=$(call any,$(TOOLS_BLD),\
255 +       dav1d.o \
256 +       dav1d_cli_parse.o \
257 +       input/annexb.o \
258 +       input/ivf.o \
259 +       input/input.o \
260 +       output/md5.o \
261 +       output/null.o \
262 +       output/output.o \
263 +       output/y4m2.o \
264 +       output/yuv.o)
265 +
266 +DAV1DPLAY_OBJS=$(call any,$(TOOLS_BLD),\
267 +       dav1dplay.o \
268 +       input/annexb.o \
269 +       input/ivf.o \
270 +       input/input.o)
271 +
272 +$(TOOLS_BLD)/%.o: tools/%.c
273 +       $(CC_CC) $(TOOLS_INCL) -o $@ -c $<
274 +
275 +DAV1D=$(TOOLS_BLD)/dav1d
276 +$(DAV1D): $(DAV1D_OBJS)
277 +       $(CC_CC) -pthread -I$(BUILD) -o $@ $(DAV1D_OBJS) $(STATIC_LIB)
278 +
279 +DAV1DPLAY=$(TOOLS_BLD)/dav1dplay
280 +$(DAV1DPLAY): $(DAV1DPLAY_OBJS)
281 +       $(CC_CC) -pthread -o $(TOOLS_BLD)/dav1dplay $(DAV1DPLAY_OBJS) $(STATIC_LIB) -lSDL2
282 +
283 +TOOLS=$(DAV1D) $(DAV1DPLAY)
284 +.PHONY:        tools
285 +tools: $(TOOLS)
286 +
287 +# tests
288 +TESTS_CHKASM=tests/checkasm
289 +TESTS_CHKASM_BLD=$(TESTS_BLD)/checkasm
290 +CHKASM_BIT8=$(TESTS_CHKASM_BLD)/bit8
291 +CHKASM_BIT16=$(TESTS_CHKASM_BLD)/bit16
292 +CHKASM_BITS= \
293 +       cdef.o \
294 +       ipred.o \
295 +       itx.o \
296 +       loopfilter.o \
297 +       looprestoration.o \
298 +       mc.o \
299 +
300 +CHKASM_BIT8_OBJS=$(call any,$(CHKASM_BIT8),$(CHKASM_BITS))
301 +CHKASM_BIT16_OBJS=$(call any,$(CHKASM_BIT16),$(CHKASM_BITS))
302 +
303 +TESTS_CHKASM_OBJS= \
304 +       $(TESTS_CHKASM_BLD)/checkasm.o \
305 +       $(TESTS_CHKASM_BLD)/msac.o \
306 +       $(CHKASM_BIT8_OBJS) $(CHKASM_BIT16_OBJS) \
307 +       $(TESTS_CHKASM_BLD)/x86/checkasm.obj \
308 +
309 +$(TESTS_CHKASM_BLD)/%.o: $(TESTS_CHKASM)/%.c
310 +       $(CC_CC) $(BLD_INCL) -o $@ -c $<
311 +$(CHKASM_BIT8)/%.o: $(TESTS_CHKASM)/%.c
312 +       $(CC_CC) $(BLD_INCL) -DBITDEPTH=8 -o $@ -c $<
313 +$(CHKASM_BIT16)/%.o: $(TESTS_CHKASM)/%.c
314 +       $(CC_CC) $(BLD_INCL) -DBITDEPTH=16 -o $@ -c $<
315 +$(TESTS_CHKASM_BLD)/x86/%.obj: $(TESTS_CHKASM)/x86/%.asm
316 +       @$(NASM) -f $(ASM_ARCH) \
317 +               -I src/ -I $(BUILD)/ -MQ $@ -MF $@.ndep \
318 +               $< -o $@
319 +
320 +CHECKASM=$(TESTS_BLD)/checkasm/checkasm
321 +$(CHECKASM): $(TESTS_CHKASM_OBJS) $(STATIC_LIB)
322 +       $(CC_CC) -pthread -o $@ $(TESTS_CHKASM_OBJS) $(STATIC_LIB) -lm
323 +
324 +TESTS_FUZZER=tests/libfuzzer
325 +TESTS_FUZZER_BLD=$(TESTS_BLD)/libfuzzer
326 +TESTS_FUZZER_OBJS= \
327 +       $(TESTS_FUZZER_BLD)/main.o \
328 +       $(TESTS_FUZZER_BLD)/dav1d_fuzzer.o \
329 +
330 +$(TESTS_FUZZER_BLD)/%.o: $(TESTS_FUZZER)/%.c
331 +       $(CC_CC) $(BLD_INCL) -o $@ -c $<
332 +
333 +DAV1D_FUZZER=$(TESTS_BLD)/dav1d_fuzzer
334 +$(DAV1D_FUZZER): $(TESTS_FUZZER_OBJS) $(STATIC_LIB)
335 +       $(CC_CC) -pthread -o $@ $(TESTS_FUZZER_OBJS) $(STATIC_LIB)
336 +
337 +TESTS=$(CHECKASM) $(DAV1D_FUZZER)
338 +.PHONY:        tests
339 +tests: $(TESTS)
340 +
341 +$(OBJDIR):
342 +       mkdir -p $@/include/dav1d \
343 +               $(BUILD)/src $(BUILD)/include \
344 +               $(ENTRY_BLD) $(NASM_BLD) \
345 +               $(SRC_BLD)/x86 $(BIT8_BLD)/x86 $(BIT16_BLD)/x86 \
346 +               $(TOOLS_BLD) $(TOOLS_BLD)/input $(TOOLS_BLD)/output \
347 +               $(TESTS_CHKASM_BLD)/bit8 $(TESTS_CHKASM_BLD)/bit16 \
348 +               $(TESTS_CHKASM_BLD)/x86 $(TESTS_FUZZER_BLD) \
349 +
350 +clean:
351 +       rm -rf $(BUILD)
352 +
353 +install:
354 +       mkdir -p $(DESTDIR)$(LIBDIR)
355 +       cp -a $(STATIC_LIB) $(DESTDIR)$(LIBDIR)
356 +       cp -a $(SHARED_LIB) $(DESTDIR)$(LIBDIR)
357 +       mkdir -p $(DESTDIR)$(INCDIR)
358 +       cp -a include/dav1d $(DESTDIR)$(INCDIR)
359 +       rm -f $(DESTDIR)$(INCDIR)/dav1d/meson.build
360 +       rm -f $(DESTDIR)$(INCDIR)/dav1d/version.h.in
361 +       cp -a $(BUILD)/include/dav1d/version.h $(DESTDIR)$(INCDIR)/version.h
362 +