picture: align pictures on 64 bytes
[vlc.git] / contrib / src / ffmpeg / rules.mak
1 # FFmpeg
2
3 #Uncomment the one you want
4 #USE_LIBAV ?= 1
5 #USE_FFMPEG ?= 1
6
7 ifndef USE_LIBAV
8 FFMPEG_HASH=eaff5fcb7cde8d1614755269773d471d3a3d1bfc
9 FFMPEG_SNAPURL := http://git.videolan.org/?p=ffmpeg.git;a=snapshot;h=$(FFMPEG_HASH);sf=tgz
10 FFMPEG_GITURL := http://git.videolan.org/git/ffmpeg.git
11 FFMPEG_LAVC_MIN := 57.37.100
12 USE_FFMPEG := 1
13 else
14 FFMPEG_HASH=e171022c24c42b1e88a51bb3b4c27f13c87c85cb
15 FFMPEG_SNAPURL := http://git.libav.org/?p=libav.git;a=snapshot;h=$(FFMPEG_HASH);sf=tgz
16 FFMPEG_GITURL := git://git.libav.org/libav.git
17 FFMPEG_LAVC_MIN := 57.16.0
18 endif
19
20 FFMPEG_BASENAME := $(subst .,_,$(subst \,_,$(subst /,_,$(FFMPEG_HASH))))
21
22 # bsf=vp9_superframe is needed to mux VP9 inside webm/mkv
23 FFMPEGCONF = \
24         --cc="$(CC)" \
25         --pkg-config="$(PKG_CONFIG)" \
26         --disable-doc \
27         --disable-encoder=vorbis \
28         --disable-decoder=opus \
29         --enable-libgsm \
30         --disable-debug \
31         --disable-avdevice \
32         --disable-devices \
33         --disable-avfilter \
34         --disable-filters \
35         --disable-protocol=concat \
36         --disable-bsfs \
37         --disable-bzlib \
38         --disable-avresample \
39         --enable-bsf=vp9_superframe
40
41 ifdef USE_FFMPEG
42 FFMPEGCONF += \
43         --disable-swresample \
44         --disable-iconv \
45         --disable-avisynth \
46         --disable-nvenc \
47         --disable-linux-perf
48 ifdef HAVE_DARWIN_OS
49 FFMPEGCONF += \
50         --disable-securetransport
51 endif
52 endif
53
54 DEPS_ffmpeg = zlib gsm
55
56 ifndef USE_LIBAV
57 FFMPEGCONF += \
58         --enable-libopenjpeg
59 DEPS_ffmpeg += openjpeg
60 endif
61
62 # Optional dependencies
63 ifndef BUILD_NETWORK
64 FFMPEGCONF += --disable-network
65 endif
66 ifdef BUILD_ENCODERS
67 FFMPEGCONF += --enable-libmp3lame --enable-libvpx --disable-decoder=libvpx_vp8 --disable-decoder=libvpx_vp9
68 ifndef USE_FFMPEG
69 FFMPEGCONF += --disable-decoder=libvpx
70 endif
71 DEPS_ffmpeg += lame $(DEPS_lame) vpx $(DEPS_vpx)
72 else
73 FFMPEGCONF += --disable-encoders --disable-muxers
74 endif
75
76 # Small size
77 ifdef WITH_OPTIMIZATION
78 ifdef ENABLE_SMALL
79 FFMPEGCONF += --enable-small
80 endif
81 ifeq ($(ARCH),arm)
82 ifdef HAVE_ARMV7A
83 FFMPEGCONF += --enable-thumb
84 endif
85 endif
86 else
87 FFMPEGCONF += --optflags=-O0
88 endif
89
90 ifdef HAVE_CROSS_COMPILE
91 FFMPEGCONF += --enable-cross-compile --disable-programs
92 ifndef HAVE_DARWIN_OS
93 FFMPEGCONF += --cross-prefix=$(HOST)-
94 endif
95 endif
96
97 # ARM stuff
98 ifeq ($(ARCH),arm)
99 FFMPEGCONF += --arch=arm
100 ifdef HAVE_NEON
101 FFMPEGCONF += --enable-neon
102 endif
103 ifdef HAVE_ARMV7A
104 FFMPEGCONF += --cpu=cortex-a8
105 endif
106 ifdef HAVE_ARMV6
107 FFMPEGCONF += --cpu=armv6 --disable-neon
108 endif
109 endif
110
111 # ARM64 stuff
112 ifeq ($(ARCH),aarch64)
113 FFMPEGCONF += --arch=aarch64
114 endif
115
116 # MIPS stuff
117 ifeq ($(ARCH),mipsel)
118 FFMPEGCONF += --arch=mips
119 endif
120 ifeq ($(ARCH),mips64el)
121 FFMPEGCONF += --arch=mips64
122 endif
123
124 # x86 stuff
125 ifeq ($(ARCH),i386)
126 ifndef HAVE_DARWIN_OS
127 FFMPEGCONF += --arch=x86
128 endif
129 endif
130
131 # x86_64 stuff
132 ifeq ($(ARCH),x86_64)
133 ifndef HAVE_DARWIN_OS
134 FFMPEGCONF += --arch=x86_64
135 endif
136 endif
137
138 # Darwin
139 ifdef HAVE_DARWIN_OS
140 FFMPEGCONF += --arch=$(ARCH) --target-os=darwin
141 ifdef USE_FFMPEG
142 FFMPEGCONF += --disable-lzma
143 endif
144 ifeq ($(ARCH),x86_64)
145 FFMPEGCONF += --cpu=core2
146 endif
147 ifdef HAVE_IOS
148 FFMPEGCONF += --enable-pic --extra-ldflags="$(EXTRA_CFLAGS)"
149 ifdef HAVE_NEON
150 FFMPEGCONF += --as="$(AS)"
151 endif
152 endif
153 endif
154
155 # Linux
156 ifdef HAVE_LINUX
157 FFMPEGCONF += --target-os=linux --enable-pic --extra-libs="-lm"
158
159 endif
160
161 ifdef HAVE_ANDROID
162 # broken text relocations
163 ifeq ($(ANDROID_ABI), x86)
164 FFMPEGCONF +=  --disable-mmx --disable-mmxext --disable-inline-asm
165 endif
166 ifeq ($(ANDROID_ABI), x86_64)
167 FFMPEGCONF +=  --disable-mmx --disable-mmxext --disable-inline-asm
168 endif
169 ifdef HAVE_NEON
170 ifeq ($(ANDROID_ABI), armeabi-v7a)
171 FFMPEGCONF += --as='gas-preprocessor.pl -as-type clang -arch arm $(CC)'
172 endif
173 endif
174 endif
175
176 # Windows
177 ifdef HAVE_WIN32
178 ifndef HAVE_VISUALSTUDIO
179 DEPS_ffmpeg += d3d11
180 ifndef HAVE_MINGW_W64
181 DEPS_ffmpeg += directx
182 endif
183 endif
184 FFMPEGCONF += --target-os=mingw32
185 FFMPEGCONF += --enable-w32threads
186 ifndef HAVE_WINSTORE
187 FFMPEGCONF += --enable-dxva2
188 else
189 FFMPEGCONF += --disable-dxva2
190 endif
191
192 ifeq ($(ARCH),x86_64)
193 FFMPEGCONF += --cpu=athlon64 --arch=x86_64
194 else
195 ifeq ($(ARCH),i386) # 32bits intel
196 FFMPEGCONF+= --cpu=i686 --arch=x86
197 else
198 ifdef HAVE_ARMV7A
199 FFMPEGCONF+= --arch=arm
200 endif
201 endif
202 endif
203
204 else # !Windows
205 FFMPEGCONF += --enable-pthreads
206 endif
207
208 # Solaris
209 ifdef HAVE_SOLARIS
210 ifeq ($(ARCH),x86_64)
211 FFMPEGCONF += --cpu=core2
212 endif
213 FFMPEGCONF += --target-os=sunos --enable-pic
214 endif
215
216 ifdef HAVE_NACL
217 FFMPEGCONF+=--disable-inline-asm --disable-asm --target-os=linux
218 endif
219
220 # Build
221 PKGS += ffmpeg
222 ifeq ($(call need_pkg,"libavcodec >= $(FFMPEG_LAVC_MIN) libavformat >= 53.21.0 libswscale"),)
223 PKGS_FOUND += ffmpeg
224 endif
225
226 FFMPEGCONF += --nm="$(NM)" --ar="$(AR)"
227
228 $(TARBALLS)/ffmpeg-$(FFMPEG_BASENAME).tar.xz:
229         $(call download_git,$(FFMPEG_GITURL),,$(FFMPEG_HASH))
230
231 .sum-ffmpeg: $(TARBALLS)/ffmpeg-$(FFMPEG_BASENAME).tar.xz
232         $(call check_githash,$(FFMPEG_HASH))
233         touch $@
234
235 ffmpeg: ffmpeg-$(FFMPEG_BASENAME).tar.xz .sum-ffmpeg
236         rm -Rf $@ $@-$(FFMPEG_BASENAME)
237         mkdir -p $@-$(FFMPEG_BASENAME)
238         tar xvJf "$<" --strip-components=1 -C $@-$(FFMPEG_BASENAME)
239         $(APPLY) $(SRC)/ffmpeg/0001-arm-vc1dsp-Add-commas-between-macro-arguments.patch
240         $(APPLY) $(SRC)/ffmpeg/0002-arm-Produce-.const_data-instead-of-.section-.rodata-.patch
241 ifdef USE_FFMPEG
242         $(APPLY) $(SRC)/ffmpeg/0003-arm-swscale-Only-compile-the-rgb2yuv-asm-if-.dn-alia.patch
243         $(APPLY) $(SRC)/ffmpeg/0004-arm-hevcdsp-Avoid-using-macro-expansion-counters.patch
244         $(APPLY) $(SRC)/ffmpeg/0005-arm-hevcdsp-Add-commas-between-macro-arguments.patch
245         $(APPLY) $(SRC)/ffmpeg/armv7_fixup.patch
246         $(APPLY) $(SRC)/ffmpeg/dxva_vc1_crash.patch
247         $(APPLY) $(SRC)/ffmpeg/h264_early_SAR.patch
248 endif
249 ifdef USE_LIBAV
250         $(APPLY) $(SRC)/ffmpeg/libav_gsm.patch
251 endif
252         $(MOVE)
253
254 .ffmpeg: ffmpeg
255         cd $< && $(HOSTVARS) ./configure \
256                 --extra-ldflags="$(LDFLAGS)" $(FFMPEGCONF) \
257                 --prefix="$(PREFIX)" --enable-static --disable-shared
258         cd $< && $(MAKE) install-libs install-headers
259         touch $@