Contribs: ffmpeg, fix hw decoding
[vlc.git] / contrib / src / ffmpeg / rules.mak
blobb129d6a897757f095205650f43a84793eb262205
1 # FFmpeg
3 #Uncomment the one you want
4 #USE_LIBAV ?= 1
5 #USE_FFMPEG ?= 1
7 ifndef USE_LIBAV
8 FFMPEG_HASH=5a93a85fd0ad62c6c9cdf69415959f116c015f0e
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 else
13 FFMPEG_HASH=e171022c24c42b1e88a51bb3b4c27f13c87c85cb
14 FFMPEG_SNAPURL := http://git.libav.org/?p=libav.git;a=snapshot;h=$(FFMPEG_HASH);sf=tgz
15 FFMPEG_GITURL := git://git.libav.org/libav.git
16 FFMPEG_LAVC_MIN := 57.16.0
17 endif
19 FFMPEG_BASENAME := $(subst .,_,$(subst \,_,$(subst /,_,$(FFMPEG_HASH))))
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-avresample
38 ifdef USE_FFMPEG
39 FFMPEGCONF += \
40 --disable-swresample \
41 --disable-iconv \
42 --disable-avisynth \
43 --disable-nvenc \
44 --disable-linux-perf
45 ifdef HAVE_DARWIN_OS
46 FFMPEGCONF += \
47 --disable-videotoolbox
48 endif
49 endif
51 DEPS_ffmpeg = zlib gsm
53 ifndef USE_LIBAV
54 FFMPEGCONF += \
55 --enable-libopenjpeg
56 DEPS_ffmpeg += openjpeg
57 endif
59 # Optional dependencies
60 ifndef BUILD_NETWORK
61 FFMPEGCONF += --disable-network
62 endif
63 ifdef BUILD_ENCODERS
64 FFMPEGCONF += --enable-libmp3lame --enable-libvpx --disable-decoder=libvpx_vp8 --disable-decoder=libvpx_vp9
65 ifndef USE_FFMPEG
66 FFMPEGCONF += --disable-decoder=libvpx
67 endif
68 DEPS_ffmpeg += lame $(DEPS_lame) vpx $(DEPS_vpx)
69 else
70 FFMPEGCONF += --disable-encoders --disable-muxers
71 endif
73 # Small size
74 ifdef WITH_OPTIMIZATION
75 ifdef ENABLE_SMALL
76 FFMPEGCONF += --enable-small
77 endif
78 ifeq ($(ARCH),arm)
79 ifdef HAVE_ARMV7A
80 FFMPEGCONF += --enable-thumb
81 endif
82 endif
83 else
84 FFMPEGCONF += --optflags=-O0
85 endif
87 ifdef HAVE_CROSS_COMPILE
88 FFMPEGCONF += --enable-cross-compile --disable-programs
89 ifndef HAVE_DARWIN_OS
90 FFMPEGCONF += --cross-prefix=$(HOST)-
91 endif
92 endif
94 # ARM stuff
95 ifeq ($(ARCH),arm)
96 FFMPEGCONF += --arch=arm
97 ifdef HAVE_NEON
98 FFMPEGCONF += --enable-neon
99 endif
100 ifdef HAVE_ARMV7A
101 FFMPEGCONF += --cpu=cortex-a8
102 endif
103 ifdef HAVE_ARMV6
104 FFMPEGCONF += --cpu=armv6 --disable-neon
105 endif
106 endif
108 # ARM64 stuff
109 ifeq ($(ARCH),aarch64)
110 FFMPEGCONF += --arch=aarch64
111 endif
113 # MIPS stuff
114 ifeq ($(ARCH),mipsel)
115 FFMPEGCONF += --arch=mips
116 endif
117 ifeq ($(ARCH),mips64el)
118 FFMPEGCONF += --arch=mips64
119 endif
121 # x86 stuff
122 ifeq ($(ARCH),i386)
123 ifndef HAVE_DARWIN_OS
124 FFMPEGCONF += --arch=x86
125 endif
126 endif
128 # x86_64 stuff
129 ifeq ($(ARCH),x86_64)
130 ifndef HAVE_DARWIN_OS
131 FFMPEGCONF += --arch=x86_64
132 endif
133 endif
135 # Darwin
136 ifdef HAVE_DARWIN_OS
137 FFMPEGCONF += --arch=$(ARCH) --target-os=darwin
138 ifdef USE_FFMPEG
139 FFMPEGCONF += --disable-lzma
140 endif
141 ifeq ($(ARCH),x86_64)
142 FFMPEGCONF += --cpu=core2
143 endif
144 ifdef HAVE_IOS
145 FFMPEGCONF += --enable-pic --extra-ldflags="$(EXTRA_CFLAGS)"
146 ifdef HAVE_NEON
147 FFMPEGCONF += --as="$(AS)"
148 endif
149 endif
150 endif
152 # Linux
153 ifdef HAVE_LINUX
154 FFMPEGCONF += --target-os=linux --enable-pic --extra-libs="-lm"
156 endif
158 ifdef HAVE_ANDROID
159 # broken text relocations
160 ifeq ($(ANDROID_ABI), x86)
161 FFMPEGCONF += --disable-mmx --disable-mmxext --disable-inline-asm
162 endif
163 ifeq ($(ANDROID_ABI), x86_64)
164 FFMPEGCONF += --disable-mmx --disable-mmxext --disable-inline-asm
165 endif
166 ifdef HAVE_NEON
167 ifeq ($(ANDROID_ABI), armeabi-v7a)
168 FFMPEGCONF += --as='gas-preprocessor.pl -as-type clang -arch arm $(CC)'
169 endif
170 endif
171 endif
173 # Windows
174 ifdef HAVE_WIN32
175 ifndef HAVE_VISUALSTUDIO
176 DEPS_ffmpeg += d3d11
177 ifndef HAVE_MINGW_W64
178 DEPS_ffmpeg += directx
179 endif
180 endif
181 FFMPEGCONF += --target-os=mingw32
182 FFMPEGCONF += --enable-w32threads
183 ifndef HAVE_WINSTORE
184 FFMPEGCONF += --enable-dxva2
185 else
186 FFMPEGCONF += --disable-dxva2
187 endif
189 ifdef HAVE_WIN64
190 FFMPEGCONF += --cpu=athlon64 --arch=x86_64
191 else
192 ifeq ($(ARCH),i386) # 32bits intel
193 FFMPEGCONF+= --cpu=i686 --arch=x86
194 else
195 ifdef HAVE_ARMV7A
196 FFMPEGCONF+= --arch=arm
197 endif
198 endif
199 endif
201 else # !Windows
202 FFMPEGCONF += --enable-pthreads
203 endif
205 # Solaris
206 ifdef HAVE_SOLARIS
207 ifeq ($(ARCH),x86_64)
208 FFMPEGCONF += --cpu=core2
209 endif
210 FFMPEGCONF += --target-os=sunos --enable-pic
211 endif
213 # Build
214 PKGS += ffmpeg
215 ifeq ($(call need_pkg,"libavcodec >= $(FFMPEG_LAVC_MIN) libavformat >= 53.21.0 libswscale"),)
216 PKGS_FOUND += ffmpeg
217 endif
219 FFMPEGCONF += --nm="$(NM)" --ar="$(AR)"
221 $(TARBALLS)/ffmpeg-$(FFMPEG_BASENAME).tar.xz:
222 $(call download_git,$(FFMPEG_GITURL),,$(FFMPEG_HASH))
224 .sum-ffmpeg: $(TARBALLS)/ffmpeg-$(FFMPEG_BASENAME).tar.xz
225 $(call check_githash,$(FFMPEG_HASH))
226 touch $@
228 ffmpeg: ffmpeg-$(FFMPEG_BASENAME).tar.xz .sum-ffmpeg
229 rm -Rf $@ $@-$(FFMPEG_BASENAME)
230 mkdir -p $@-$(FFMPEG_BASENAME)
231 tar xvJf "$<" --strip-components=1 -C $@-$(FFMPEG_BASENAME)
232 ifdef USE_FFMPEG
233 $(APPLY) $(SRC)/ffmpeg/armv7_fixup.patch
234 $(APPLY) $(SRC)/ffmpeg/lavc-change-HW_CONFIG_HWACCEL-arguments.patch
235 $(APPLY) $(SRC)/ffmpeg/lavc-add-back-AD_HOC-method-for-DXVA2-D3D11-VAAPI-VDPAU.patch
236 endif
237 ifdef USE_LIBAV
238 $(APPLY) $(SRC)/ffmpeg/libav_gsm.patch
239 endif
240 $(MOVE)
242 .ffmpeg: ffmpeg
243 cd $< && $(HOSTVARS) ./configure \
244 --extra-ldflags="$(LDFLAGS)" $(FFMPEGCONF) \
245 --prefix="$(PREFIX)" --enable-static --disable-shared
246 cd $< && $(MAKE) install-libs install-headers
247 touch $@