extras: ci: update Android image and NDK (21)
[vlc.git] / contrib / src / ffmpeg / rules.mak
blobbe625e4478458051697e1113435532b444c127a3
1 # FFmpeg
3 #Uncomment the one you want
4 #USE_LIBAV ?= 1
5 #USE_FFMPEG ?= 1
7 ifndef USE_LIBAV
8 FFMPEG_HASH=1e35519fe0b8bbad84641e83d49138152720b544
9 FFMPEG_GITURL := http://git.videolan.org/git/ffmpeg.git
10 FFMPEG_LAVC_MIN := 57.37.100
11 USE_FFMPEG := 1
12 else
13 FFMPEG_HASH=e5afa1b556542fd7a52a0a9b409c80f2e6e1e9bb
14 FFMPEG_GITURL := git://git.libav.org/libav.git
15 FFMPEG_LAVC_MIN := 57.16.0
16 endif
18 FFMPEG_BASENAME := $(subst .,_,$(subst \,_,$(subst /,_,$(FFMPEG_HASH))))
20 # bsf=vp9_superframe is needed to mux VP9 inside webm/mkv
21 FFMPEGCONF = \
22 --cc="$(CC)" \
23 --pkg-config="$(PKG_CONFIG)" \
24 --disable-doc \
25 --disable-encoder=vorbis \
26 --disable-decoder=opus \
27 --enable-libgsm \
28 --disable-debug \
29 --disable-avdevice \
30 --disable-devices \
31 --disable-avfilter \
32 --disable-filters \
33 --disable-protocol=concat \
34 --disable-bsfs \
35 --disable-bzlib \
36 --disable-libvpx \
37 --disable-avresample \
38 --enable-bsf=vp9_superframe
40 ifdef USE_FFMPEG
41 FFMPEGCONF += \
42 --disable-swresample \
43 --disable-iconv \
44 --disable-avisynth \
45 --disable-nvenc \
46 --disable-linux-perf
47 ifdef HAVE_DARWIN_OS
48 FFMPEGCONF += \
49 --disable-securetransport
50 endif
51 endif
53 # Disable VDA on macOS with libav
54 ifdef USE_LIBAV
55 ifdef HAVE_DARWIN_OS
56 FFMPEGCONF += \
57 --disable-vda
58 endif
59 endif
61 DEPS_ffmpeg = zlib gsm
63 ifndef USE_LIBAV
64 FFMPEGCONF += \
65 --enable-libopenjpeg
66 DEPS_ffmpeg += openjpeg $(DEPS_openjpeg)
67 endif
69 # Optional dependencies
70 ifndef BUILD_NETWORK
71 FFMPEGCONF += --disable-network
72 endif
73 ifdef BUILD_ENCODERS
74 FFMPEGCONF += --enable-libmp3lame
75 DEPS_ffmpeg += lame $(DEPS_lame)
76 else
77 FFMPEGCONF += --disable-encoders --disable-muxers
78 endif
80 # Small size
81 ifdef WITH_OPTIMIZATION
82 ifdef ENABLE_SMALL
83 FFMPEGCONF += --enable-small
84 endif
85 ifeq ($(ARCH),arm)
86 ifdef HAVE_ARMV7A
87 FFMPEGCONF += --enable-thumb
88 endif
89 endif
90 else
91 FFMPEGCONF += --optflags=-Og
92 endif
94 ifdef HAVE_CROSS_COMPILE
95 FFMPEGCONF += --enable-cross-compile --disable-programs
96 ifndef HAVE_DARWIN_OS
97 FFMPEGCONF += --cross-prefix=$(HOST)-
98 endif
99 endif
101 # ARM stuff
102 ifeq ($(ARCH),arm)
103 FFMPEGCONF += --arch=arm
104 ifdef HAVE_NEON
105 FFMPEGCONF += --enable-neon
106 endif
107 ifdef HAVE_ARMV7A
108 FFMPEGCONF += --cpu=cortex-a8
109 endif
110 ifdef HAVE_ARMV6
111 FFMPEGCONF += --cpu=armv6 --disable-neon
112 endif
113 endif
115 # ARM64 stuff
116 ifeq ($(ARCH),aarch64)
117 FFMPEGCONF += --arch=aarch64
118 endif
120 # MIPS stuff
121 ifeq ($(ARCH),mipsel)
122 FFMPEGCONF += --arch=mips
123 endif
124 ifeq ($(ARCH),mips64el)
125 FFMPEGCONF += --arch=mips64
126 endif
128 # x86 stuff
129 ifeq ($(ARCH),i386)
130 ifndef HAVE_DARWIN_OS
131 FFMPEGCONF += --arch=x86
132 endif
133 endif
135 # x86_64 stuff
136 ifeq ($(ARCH),x86_64)
137 ifndef HAVE_DARWIN_OS
138 FFMPEGCONF += --arch=x86_64
139 endif
140 endif
142 # Darwin
143 ifdef HAVE_DARWIN_OS
144 FFMPEGCONF += --arch=$(ARCH) --target-os=darwin --extra-cflags="$(CFLAGS)"
145 ifdef USE_FFMPEG
146 FFMPEGCONF += --disable-lzma
147 endif
148 ifeq ($(ARCH),x86_64)
149 FFMPEGCONF += --cpu=core2
150 endif
151 ifdef HAVE_IOS
152 FFMPEGCONF += --enable-pic --extra-ldflags="$(EXTRA_CFLAGS) -isysroot $(IOS_SDK)"
153 ifdef HAVE_NEON
154 FFMPEGCONF += --as="$(AS)"
155 endif
156 endif
157 endif
159 # Linux
160 ifdef HAVE_LINUX
161 FFMPEGCONF += --target-os=linux --enable-pic --extra-libs="-lm"
163 endif
165 ifdef HAVE_ANDROID
166 # broken text relocations
167 ifeq ($(ANDROID_ABI), x86)
168 FFMPEGCONF += --disable-mmx --disable-mmxext --disable-inline-asm
169 endif
170 ifeq ($(ANDROID_ABI), x86_64)
171 FFMPEGCONF += --disable-mmx --disable-mmxext --disable-inline-asm
172 endif
173 endif
175 # Windows
176 ifdef HAVE_WIN32
177 ifndef HAVE_VISUALSTUDIO
178 DEPS_ffmpeg += wine-headers
179 endif
180 FFMPEGCONF += --target-os=mingw32
181 FFMPEGCONF += --enable-w32threads
182 ifndef HAVE_WINSTORE
183 FFMPEGCONF += --enable-dxva2
184 else
185 FFMPEGCONF += --disable-dxva2
186 endif
188 ifeq ($(ARCH),x86_64)
189 FFMPEGCONF += --cpu=athlon64 --arch=x86_64
190 else
191 ifeq ($(ARCH),i386) # 32bits intel
192 FFMPEGCONF+= --cpu=i686 --arch=x86
193 else
194 ifdef HAVE_ARMV7A
195 FFMPEGCONF+= --arch=arm
196 endif
197 endif
198 endif
200 else # !Windows
201 FFMPEGCONF += --enable-pthreads
202 endif
204 # Solaris
205 ifdef HAVE_SOLARIS
206 ifeq ($(ARCH),x86_64)
207 FFMPEGCONF += --cpu=core2
208 endif
209 FFMPEGCONF += --target-os=sunos --enable-pic
210 endif
212 ifdef HAVE_NACL
213 FFMPEGCONF+=--disable-inline-asm --disable-asm --target-os=linux
214 endif
216 # Build
217 PKGS += ffmpeg
218 ifeq ($(call need_pkg,"libavcodec >= $(FFMPEG_LAVC_MIN) libavformat >= 53.21.0 libswscale"),)
219 PKGS_FOUND += ffmpeg
220 endif
222 FFMPEGCONF += --nm="$(NM)" --ar="$(AR)" --ranlib="$(RANLIB)"
224 $(TARBALLS)/ffmpeg-$(FFMPEG_BASENAME).tar.xz:
225 $(call download_git,$(FFMPEG_GITURL),,$(FFMPEG_HASH))
227 .sum-ffmpeg: $(TARBALLS)/ffmpeg-$(FFMPEG_BASENAME).tar.xz
228 $(call check_githash,$(FFMPEG_HASH))
229 touch $@
231 ffmpeg: ffmpeg-$(FFMPEG_BASENAME).tar.xz .sum-ffmpeg
232 $(UNPACK)
233 ifdef USE_FFMPEG
234 $(APPLY) $(SRC)/ffmpeg/armv7_fixup.patch
235 $(APPLY) $(SRC)/ffmpeg/dxva_vc1_crash.patch
236 $(APPLY) $(SRC)/ffmpeg/h264_early_SAR.patch
237 $(APPLY) $(SRC)/ffmpeg/0001-avcodec-dxva2_hevc-add-support-for-parsing-HEVC-Rang.patch
238 $(APPLY) $(SRC)/ffmpeg/0002-avcodec-hevcdec-allow-HEVC-444-8-10-12-bits-decoding.patch
239 $(APPLY) $(SRC)/ffmpeg/0003-avcodec-hevcdec-allow-HEVC-422-10-12-bits-decoding-w.patch
240 endif
241 ifdef USE_LIBAV
242 $(APPLY) $(SRC)/ffmpeg/libav_gsm.patch
243 endif
244 $(MOVE)
246 .ffmpeg: ffmpeg
247 cd $< && $(HOSTVARS) ./configure \
248 --extra-ldflags="$(LDFLAGS)" $(FFMPEGCONF) \
249 --prefix="$(PREFIX)" --enable-static --disable-shared
250 cd $< && $(MAKE) install-libs install-headers
251 touch $@