cut with active speed auto correction, add locale pref, mod prores dft profile to...
[goodguy/cinelerra.git] / cinelerra-5.1 / thirdparty / src / dav1d-0.7.1.patch1
1 diff -ruN dav1d-0.7.1.orig/Makefile dav1d-0.7.1/Makefile
2 --- dav1d-0.7.1.orig/Makefile   1969-12-31 17:00:00.000000000 -0700
3 +++ dav1d-0.7.1/Makefile        2020-07-09 20:10:47.066626832 -0600
4 @@ -0,0 +1,371 @@
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 -D_GNU_SOURCE
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=6 \
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.3 \
92 +       -Wl,--end-group \
93 +       -pthread -ldl \
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_avx512.obj \
102 +       cdef_avx2.obj \
103 +       film_grain.obj \
104 +       ipred.obj \
105 +       itx.obj \
106 +       cdef_sse.obj \
107 +       film_grain_ssse3.obj \
108 +       ipred_ssse3.obj \
109 +       loopfilter.obj \
110 +       looprestoration.obj \
111 +       mc.obj \
112 +       itx_ssse3.obj \
113 +       looprestoration_ssse3.obj \
114 +       loopfilter_ssse3.obj \
115 +       mc_sse.obj \
116 +       cpuid.obj \
117 +       msac.obj )
118 +
119 +$(NASM_BLD)/%.obj: src/x86/%.asm
120 +       $(NASM) -f $(ASM_ARCH) \
121 +               -I src/ -I $(BUILD)/ -MQ $@ -MF $@.ndep \
122 +               $< -o $@
123 +
124 +# entry
125 +ENTRY_OBJS=$(call any,$(ENTRY_BLD), \
126 +       lib.c.o \
127 +       thread_task.c.o)
128 +$(ENTRY_BLD)/%.c.o: src/%.c
129 +       $(CC_CC) -Iinclude -Ibuild/include/dav1d -Isrc/entry $(BLD_INCL) \
130 +               -mincoming-stack-boundary=4 -o $@ -c $<
131 +
132 +# src
133 +SRC_OBJS=$(call any,$(SRC_BLD), \
134 +       cdf.o \
135 +       cpu.o \
136 +       data.o \
137 +       decode.o \
138 +       dequant_tables.o \
139 +       getbits.o \
140 +       intra_edge.o \
141 +       itx_1d.o \
142 +       lf_mask.o \
143 +       log.o \
144 +       msac.o \
145 +       obu.o \
146 +       picture.o \
147 +       qm.o \
148 +       ref.o \
149 +       refmvs.o \
150 +       scan.o \
151 +       tables.o \
152 +       warpmv.o \
153 +       wedge.o \
154 +       x86/cpu.c.o \
155 +       x86/msac_init.c.o)
156 +$(SRC_BLD)/%.o: src/%.c
157 +       $(CC_CC) $(BLD_INCL) -pthread -o $@ -c $<
158 +$(SRC_BLD)/x86/%.c.o: src/x86/%.c
159 +       $(CC_CC) $(BLD_INCL) -o $@ -c $<
160 +
161 +# bits
162 +BITS_OBJS= \
163 +       cdef_tmpl.o \
164 +       cdef_apply_tmpl.o \
165 +       fg_apply_tmpl.o \
166 +       film_grain_tmpl.o \
167 +       ipred_tmpl.o \
168 +       ipred_prepare_tmpl.o \
169 +       itx_tmpl.o \
170 +       lf_apply_tmpl.o \
171 +       loopfilter_tmpl.o \
172 +       looprestoration_tmpl.o \
173 +       lr_apply_tmpl.o \
174 +       mc_tmpl.o \
175 +       recon_tmpl.o \
176 +       x86/cdef_init_tmpl.c.o \
177 +       x86/film_grain_init_tmpl.c.o \
178 +       x86/ipred_init_tmpl.c.o \
179 +       x86/itx_init_tmpl.c.o \
180 +       x86/loopfilter_init_tmpl.c.o \
181 +       x86/looprestoration_init_tmpl.c.o \
182 +       x86/mc_init_tmpl.c.o \
183 +
184 +BIT8_OBJS=$(call any,$(BIT8_BLD),$(BITS_OBJS))
185 +$(BIT8_BLD)/x86/%.c.o: src/x86/%.c
186 +       $(CC_CC) $(BLD_INCL) -DBITDEPTH=8 -o $@ -c $<
187 +$(BIT8_BLD)/%.o: src/%.c
188 +       $(CC_CC) $(BLD_INCL) -DBITDEPTH=8 -o $@ -c $<
189 +
190 +BIT16_OBJS=$(call any,$(BIT16_BLD),$(BITS_OBJS))
191 +$(BIT16_BLD)/x86/%.c.o: src/x86/%.c
192 +       $(CC_CC) $(BLD_INCL) -DBITDEPTH=16 -o $@ -c $<
193 +$(BIT16_BLD)/%.o: src/%.c
194 +       $(CC_CC) $(BLD_INCL) -DBITDEPTH=16 -o $@ -c $<
195 +
196 +$(BUILD)/config.h:
197 +       echo  > $@ "#pragma once"
198 +       echo >> $@ "#define ARCH_AARCH64 0"
199 +       echo >> $@ "#define ARCH_ARM 0"
200 +       echo >> $@ "#define ARCH_PPC64LE 0"
201 +       echo >> $@ "#define ARCH_X86 1"
202 +       echo >> $@ "#define ARCH_X86_32 $(ARCH_X86_32)"
203 +       echo >> $@ "#define ARCH_X86_64 $(ARCH_X86_64)"
204 +       echo >> $@ "#define CONFIG_16BPC 1"
205 +       echo >> $@ "#define CONFIG_8BPC 1"
206 +       echo >> $@ "#define CONFIG_LOG 1"
207 +       echo >> $@ "#define ENDIANNESS_BIG 0"
208 +       echo >> $@ "#define HAVE_ASM 1"
209 +       echo >> $@ "#define HAVE_AVX512ICL 1"
210 +       echo >> $@ "#define HAVE_CLOCK_GETTIME 1"
211 +       echo >> $@ "#define HAVE_DLSYM 1"
212 +       echo >> $@ "#define HAVE_POSIX_MEMALIGN 1"
213 +       echo >> $@ "#define HAVE_UNISTD_H 1"
214 +       echo >> $@ "#define STACK_ALIGNMENT 32"
215 +
216 +$(BUILD)/config.asm:
217 +       echo  > $@ "%define ARCH_X86_32 $(ARCH_X86_32)"
218 +       echo >> $@ "%define ARCH_X86_64 $(ARCH_X86_64)"
219 +       echo >> $@ "%define PIC 1"
220 +       echo >> $@ "%define STACK_ALIGNMENT 32"
221 +       echo >> $@ "%define HAVE_AVX512ICL 1"
222 +
223 +$(BUILD)/include/vcs_version.h:
224 +       mkdir -p $(BUILD)/include
225 +       echo  > $@ "#define DAV1D_VERSION \"0.7.1\""
226 +
227 +$(BUILD)/include/dav1d/version.h:
228 +       mkdir -p $(BUILD)/include/dav1d
229 +       echo  > $@ "#ifndef DAV1D_VERSION_H"
230 +       echo >> $@ "#define DAV1D_VERSION_H"
231 +       echo >> $@ "#define DAV1D_API_VERSION_MAJOR 3"
232 +       echo >> $@ "#define DAV1D_API_VERSION_MINOR 0"
233 +       echo >> $@ "#define DAV1D_API_VERSION_PATCH 0"
234 +       echo >> $@ "#endif /* DAV1D_VERSION_H */"
235 +
236 +$(TOOLS_BLD)/cli_config.h:
237 +       mkdir -p $(TOOLS_BLD)
238 +       echo  > $@ "#pragma once"
239 +       echo >> $@ "#define HAVE_CLOCK_GETTIME 1"
240 +
241 +.PHONY: meson_data
242 +meson_data:
243 +       make meson_dirs OBJDIR=$(BUILD)/static
244 +       make meson_dirs OBJDIR=$(BUILD)/shared
245 +       ln -sf ./include/compat/gcc/stdatomic.h .
246 +
247 +.PHONY: meson_dirs
248 +meson_dirs: $(OBJDIR) \
249 +       $(BUILD)/config.h $(BUILD)/config.asm \
250 +       $(BUILD)/include/vcs_version.h \
251 +       $(BUILD)/include/dav1d/version.h \
252 +       $(TOOLS_BLD)/cli_config.h \
253 +
254 +LIB_OBJS=$(ENTRY_OBJS) $(NASM_OBJS) $(SRC_OBJS) $(BIT8_OBJS) $(BIT16_OBJS)
255 +
256 +$(STATIC_LIB): DIR?=static
257 +$(STATIC_LIB): $(LIB_OBJS)
258 +       rm -f $@
259 +       gcc-ar csrD $@ $(LIB_OBJS)
260 +
261 +$(SHARED_LIB): DIR?=shared
262 +$(SHARED_LIB): $(LIB_OBJS)
263 +       rm -f $@
264 +       cc -o $@ $(LIB_OBJS) $(SHA_OPTS)
265 +
266 +# tools
267 +DAV1D_OBJS=$(call any,$(TOOLS_BLD),\
268 +       dav1d.o \
269 +       dav1d_cli_parse.o \
270 +       input/annexb.o \
271 +       input/ivf.o \
272 +       input/input.o \
273 +       output/md5.o \
274 +       output/null.o \
275 +       output/output.o \
276 +       output/y4m2.o \
277 +       output/yuv.o)
278 +
279 +DAV1DPLAY_OBJS=$(call any,$(TOOLS_BLD),\
280 +       dav1dplay.o \
281 +       input/annexb.o \
282 +       input/ivf.o \
283 +       input/input.o)
284 +
285 +$(TOOLS_BLD)/%.o: tools/%.c
286 +       $(CC_CC) $(TOOLS_INCL) -o $@ -c $<
287 +
288 +DAV1D=$(TOOLS_BLD)/dav1d
289 +$(DAV1D): $(DAV1D_OBJS)
290 +       $(CC_CC) -pthread -I$(BUILD) -o $@ $(DAV1D_OBJS) $(STATIC_LIB)
291 +
292 +DAV1DPLAY=$(TOOLS_BLD)/dav1dplay
293 +$(DAV1DPLAY): $(DAV1DPLAY_OBJS)
294 +       $(CC_CC) -pthread -o $(TOOLS_BLD)/dav1dplay $(DAV1DPLAY_OBJS) $(STATIC_LIB) -lSDL2
295 +
296 +TOOLS=$(DAV1D) $(DAV1DPLAY)
297 +.PHONY:        tools
298 +tools: $(TOOLS)
299 +
300 +# tests
301 +TESTS_CHKASM=tests/checkasm
302 +TESTS_CHKASM_BLD=$(TESTS_BLD)/checkasm
303 +CHKASM_BIT8=$(TESTS_CHKASM_BLD)/bit8
304 +CHKASM_BIT16=$(TESTS_CHKASM_BLD)/bit16
305 +CHKASM_BITS= \
306 +       cdef.o \
307 +       ipred.o \
308 +       itx.o \
309 +       loopfilter.o \
310 +       looprestoration.o \
311 +       mc.o \
312 +
313 +CHKASM_BIT8_OBJS=$(call any,$(CHKASM_BIT8),$(CHKASM_BITS))
314 +CHKASM_BIT16_OBJS=$(call any,$(CHKASM_BIT16),$(CHKASM_BITS))
315 +
316 +TESTS_CHKASM_OBJS= \
317 +       $(TESTS_CHKASM_BLD)/checkasm.o \
318 +       $(TESTS_CHKASM_BLD)/msac.o \
319 +       $(CHKASM_BIT8_OBJS) $(CHKASM_BIT16_OBJS) \
320 +       $(TESTS_CHKASM_BLD)/x86/checkasm.obj \
321 +
322 +$(TESTS_CHKASM_BLD)/%.o: $(TESTS_CHKASM)/%.c
323 +       $(CC_CC) $(BLD_INCL) -o $@ -c $<
324 +$(CHKASM_BIT8)/%.o: $(TESTS_CHKASM)/%.c
325 +       $(CC_CC) $(BLD_INCL) -DBITDEPTH=8 -o $@ -c $<
326 +$(CHKASM_BIT16)/%.o: $(TESTS_CHKASM)/%.c
327 +       $(CC_CC) $(BLD_INCL) -DBITDEPTH=16 -o $@ -c $<
328 +$(TESTS_CHKASM_BLD)/x86/%.obj: $(TESTS_CHKASM)/x86/%.asm
329 +       @$(NASM) -f $(ASM_ARCH) \
330 +               -I src/ -I $(BUILD)/ -MQ $@ -MF $@.ndep \
331 +               $< -o $@
332 +
333 +CHECKASM=$(TESTS_BLD)/checkasm/checkasm
334 +$(CHECKASM): $(TESTS_CHKASM_OBJS) $(STATIC_LIB)
335 +       $(CC_CC) -pthread -o $@ $(TESTS_CHKASM_OBJS) $(STATIC_LIB) -lm
336 +
337 +TESTS_FUZZER=tests/libfuzzer
338 +TESTS_FUZZER_BLD=$(TESTS_BLD)/libfuzzer
339 +TESTS_FUZZER_OBJS= \
340 +       $(TESTS_FUZZER_BLD)/main.o \
341 +       $(TESTS_FUZZER_BLD)/dav1d_fuzzer.o \
342 +
343 +$(TESTS_FUZZER_BLD)/%.o: $(TESTS_FUZZER)/%.c
344 +       $(CC_CC) $(BLD_INCL) -o $@ -c $<
345 +
346 +DAV1D_FUZZER=$(TESTS_BLD)/dav1d_fuzzer
347 +$(DAV1D_FUZZER): $(TESTS_FUZZER_OBJS) $(STATIC_LIB)
348 +       $(CC_CC) -pthread -o $@ $(TESTS_FUZZER_OBJS) $(STATIC_LIB)
349 +
350 +TESTS=$(CHECKASM) $(DAV1D_FUZZER)
351 +.PHONY:        tests
352 +tests: $(TESTS)
353 +
354 +$(OBJDIR):
355 +       mkdir -p $@/include/dav1d \
356 +               $(BUILD)/src $(BUILD)/include \
357 +               $(ENTRY_BLD) $(NASM_BLD) \
358 +               $(SRC_BLD)/x86 $(BIT8_BLD)/x86 $(BIT16_BLD)/x86 \
359 +               $(TOOLS_BLD) $(TOOLS_BLD)/input $(TOOLS_BLD)/output \
360 +               $(TESTS_CHKASM_BLD)/bit8 $(TESTS_CHKASM_BLD)/bit16 \
361 +               $(TESTS_CHKASM_BLD)/x86 $(TESTS_FUZZER_BLD) \
362 +
363 +clean:
364 +       rm -rf $(BUILD)
365 +
366 +install:
367 +       mkdir -p $(DESTDIR)$(LIBDIR)
368 +       cp -a $(STATIC_LIB) $(DESTDIR)$(LIBDIR)
369 +       cp -a $(SHARED_LIB) $(DESTDIR)$(LIBDIR)
370 +       mkdir -p $(DESTDIR)$(INCDIR)
371 +       cp -a include/dav1d $(DESTDIR)$(INCDIR)
372 +       rm -f $(DESTDIR)$(INCDIR)/dav1d/meson.build
373 +       rm -f $(DESTDIR)$(INCDIR)/dav1d/version.h.in
374 +       cp -a $(BUILD)/include/dav1d/version.h $(DESTDIR)$(INCDIR)/version.h
375 +