ffmpeg: enable lto build for arm and x86_64
[feed/packages.git] / multimedia / ffmpeg / Makefile
index f87401444dc7ecbc4ff1bd51abf8093803253303..9dda6a73ffa7b95188997418b9b84d4d3cb63b89 100644 (file)
@@ -1,5 +1,6 @@
 #
 # Copyright (C) 2006-2017 OpenWrt.org
+# Copyright (C) 2017 Ian Leonard <antonlacon@gmail.com>
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -8,14 +9,14 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=ffmpeg
-PKG_VERSION:=3.2.2
+PKG_VERSION:=3.2.7
 PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=https://ffmpeg.org/releases/
-PKG_MD5SUM:=e34d1b92c5d844f2a3611c741a6dba18
-PKG_HASH:=3f01bd1fe1a17a277f8c84869e5d9192b4b978cb660872aa2b54c3cc8a2fedfc
-PKG_MAINTAINER:=Ted Hess <thess@kitschensync.net>
+PKG_HASH:=28e75fc32485a88035a7ebf0a956a1e5c7e93b440dd4bbd6bc30c7268cf34fe9
+PKG_MAINTAINER:=Ted Hess <thess@kitschensync.net>, \
+               Ian Leonard <antonlacon@gmail.com>
 
 PKG_LICENSE:=LGPL-2.1+ GPL-2+ LGPL-3
 PKG_LICENSE_FILES:=COPYING.GPLv2 COPYING.GPLv3 COPYING.LGPLv2.1 COPYING.LGPLv3
@@ -148,7 +149,7 @@ FFMPEG_MINI_DEMUXERS:= \
        ogg \
 
 FFMPEG_MINI_PROTOCOLS:= \
-       file \
+       file
 
 FFMPEG_AUDIO_DECODERS:= \
        aac \
@@ -198,14 +199,6 @@ FFMPEG_AUDIO_DEMUXERS:= \
        wav \
        wv \
 
-FFMPEG_AUDIO_PARSERS:= \
-       aac \
-       aac_latm \
-       ac3 \
-       flac \
-       mpegaudio \
-       opus \
-
 FFMPEG_AUDIO_PROTOCOLS:= \
        file http icecast rtp tcp udp
 
@@ -224,7 +217,8 @@ include $(INCLUDE_DIR)/package.mk
 
 define Package/ffmpeg/Default
  TITLE:=FFmpeg
- URL:=http://ffmpeg.mplayerhq.hu/
+ URL:=https://ffmpeg.org/
+ DEPENDS+= +libpthread
 endef
 
 define Package/ffmpeg/Default/description
@@ -238,7 +232,7 @@ $(call Package/ffmpeg/Default)
  SECTION:=multimedia
  CATEGORY:=Multimedia
  TITLE+= program
- DEPENDS+= +libpthread +libffmpeg-full
+ DEPENDS+= +libffmpeg-full
  VARIANT:=full
 endef
 
@@ -270,7 +264,7 @@ $(call Package/ffserver/Default)
  SECTION:=multimedia
  CATEGORY:=Multimedia
  TITLE+= streaming server
- DEPENDS+= +libpthread +libffmpeg-full
+ DEPENDS+= +libffmpeg-full
  VARIANT:=full
 endef
 
@@ -285,7 +279,7 @@ $(call Package/ffmpeg/Default)
  SECTION:=libs
  CATEGORY:=Libraries
  TITLE+= libraries
- DEPENDS+= @BUILD_PATENTED +libpthread +zlib +libbz2
+ DEPENDS+= +libpthread +zlib +libbz2
  PROVIDES:= libffmpeg
 endef
 
@@ -294,8 +288,9 @@ define Package/libffmpeg-custom
 $(call Package/libffmpeg/Default)
  TITLE+= (custom)
  DEPENDS+= +FFMPEG_CUSTOM_SELECT_libopus:libopus \
-           +PACKAGE_libx264:libx264 +PACKAGE_lame-lib:lame-lib
-
+           +PACKAGE_libx264:libx264 +PACKAGE_lame-lib:lame-lib \
+           +FFMPEG_CUSTOM_SELECT_libshine:shine \
+           +PACKAGE_fdk-aac:fdk-aac
  VARIANT:=custom
  MENU:=1
 endef
@@ -314,6 +309,7 @@ endef
 define Package/libffmpeg-audio-dec
 $(call Package/libffmpeg/Default)
  TITLE+= (audio)
+ DEPENDS+= @BUILD_PATENTED
  VARIANT:=audio-dec
 endef
 
@@ -327,10 +323,16 @@ endef
 define Package/libffmpeg-full
 $(call Package/libffmpeg/Default)
  TITLE+= (full)
- DEPENDS+= +alsa-lib +PACKAGE_libx264:libx264 +PACKAGE_lame-lib:lame-lib +libopus
+ DEPENDS+= @BUILD_PATENTED +alsa-lib +PACKAGE_libopus:libopus
+ ifeq ($(CONFIG_SOFT_FLOAT),y)
+       DEPENDS+= +PACKAGE_shine:shine
+ else
+       DEPENDS+= +PACKAGE_lame-lib:lame-lib +PACKAGE_libx264:libx264
+ endif
  VARIANT:=full
 endef
 
+
 define Package/libffmpeg-full/description
 $(call Package/ffmpeg/Default/description)
  .
@@ -341,6 +343,7 @@ endef
 define Package/libffmpeg-mini
 $(call Package/libffmpeg/Default)
  TITLE+= (mini)
+ DEPENDS+= @BUILD_PATENTED
  VARIANT:=mini
 endef
 
@@ -363,43 +366,21 @@ FFMPEG_CONFIGURE:= \
        --pkg-config="pkg-config" \
        --enable-shared \
        --enable-static \
-       --enable-small \
        --enable-pthreads \
        --enable-zlib \
        --disable-doc \
        --disable-debug \
        \
-       --enable-gpl \
-       --enable-version3 \
-       \
-       --disable-dxva2 \
        --disable-lzma \
        --disable-vaapi \
-       --disable-vda \
        --disable-vdpau \
        --disable-outdevs
 
 ifeq ($(CONFIG_SOFT_FLOAT),y)
-FFMPEG_CONFIGURE += \
+FFMPEG_CONFIGURE+= \
        --disable-altivec \
        --disable-vsx \
        --disable-power8 \
-       --disable-amd3dnow \
-       --disable-amd3dnowext \
-       --disable-mmx \
-       --disable-mmxext \
-       --disable-sse \
-       --disable-sse2 \
-       --disable-sse3 \
-       --disable-ssse3 \
-       --disable-sse4 \
-       --disable-sse42 \
-       --disable-avx \
-       --disable-xop \
-       --disable-fma3 \
-       --disable-fma4 \
-       --disable-avx2 \
-       --disable-aesni \
        --disable-armv5te \
        --disable-armv6 \
        --disable-armv6t2 \
@@ -413,37 +394,63 @@ FFMPEG_CONFIGURE += \
        --disable-runtime-cpudetect
 
 else ifneq ($(findstring arm,$(CONFIG_ARCH)),)
-FFMPEG_CONFIGURE += \
+FFMPEG_CONFIGURE+= \
        --disable-runtime-cpudetect
+# XXX: GitHub issue 3320 ppc cpu with fpu but no altivec (WNDR4700)
 else ifneq ($(findstring powerpc,$(CONFIG_ARCH)),)
-FFMPEG_CONFIGURE += \
+FFMPEG_CONFIGURE+= \
        --disable-altivec
 endif
 
-ifneq ($(CONFIG_YASM),y)
-FFMPEG_CONFIGURE += \
-       --disable-yasm
-
-endif
-
-#selectibly disable optimizations according to arch/cpu type
+# selectively disable optimizations according to arch/cpu type
 ifneq ($(findstring arm,$(CONFIG_ARCH)),)
-       ifeq (,$(findstring vfp,$(CONFIG_TARGET_OPTIMIZATION)))
-               FFMPEG_CONFIGURE+= \
-                       --disable-vfp
+       FFMPEG_CONFIGURE+= --enable-lto
+
+       ifneq ($(findstring vfp,$(CONFIG_TARGET_OPTIMIZATION)),)
+               FFMPEG_CONFIGURE+= --enable-vfp
+       else
+               FFMPEG_CONFIGURE+= --disable-vfp
        endif
-       ifeq (,$(findstring neon,$(CONFIG_TARGET_OPTIMIZATION)))
+       ifneq ($(findstring neon,$(CONFIG_TARGET_OPTIMIZATION)),)
                FFMPEG_CONFIGURE+= \
-                       --disable-neon
+                       --enable-neon \
+                       --enable-vfp
+       else
+               FFMPEG_CONFIGURE+= --disable-neon
        endif
 
 endif
 
+ifeq ($(ARCH),x86_64)
+       FFMPEG_CONFIGURE+= --enable-lto
+endif
+
+ifneq ($(CONFIG_YASM),y)
+FFMPEG_CONFIGURE+= --disable-yasm
+
+endif
+
 ifeq ($(BUILD_VARIANT),full)
        FFMPEG_CONFIGURE+= \
-               --enable-libopus --enable-decoder=libopus \
-               $(if $(CONFIG_PACKAGE_libx264),--enable-libx264) \
-               $(if $(CONFIG_PACKAGE_lame-lib),--enable-libmp3lame)
+               --enable-avresample \
+               $(if $(CONFIG_PACKAGE_libopus),--enable-libopus)
+  ifeq ($(CONFIG_SOFT_FLOAT),y)
+       FFMPEG_CONFIGURE+= \
+               --enable-small \
+               \
+               $(if $(CONFIG_PACKAGE_shine),--enable-libshine)
+  else
+       ifeq ($(ARCH),x86_64)
+               FFMPEG_CONFIGURE+= --enable-hardcoded-tables
+       else
+               FFMPEG_CONFIGURE+= --enable-small
+       endif
+       FFMPEG_CONFIGURE+= \
+               --enable-gpl \
+               \
+               $(if $(CONFIG_PACKAGE_lame-lib),--enable-libmp3lame) \
+               $(if $(CONFIG_PACKAGE_libx264),--enable-libx264)
+  endif
 endif
 
 ifeq ($(BUILD_VARIANT),custom)
@@ -453,6 +460,26 @@ ifeq ($(BUILD_VARIANT),custom)
                $(if $($(3)_$(c)),--enable-$(1)="$(c)") \
        )
 
+  ifeq ($(CONFIG_FFMPEG_CUSTOM_LARGE),y)
+       FFMPEG_CONFIGURE+= \
+               --enable-hardcoded-tables
+  else
+       FFMPEG_CONFIGURE+= \
+               --enable-small
+  endif
+
+  ifeq ($(CONFIG_FFMPEG_CUSTOM_GPL),y)
+       FFMPEG_CONFIGURE+= --enable-gpl
+  endif
+
+  ifeq ($(CONFIG_FFMPEG_CUSTOM_GPLV3),y)
+       FFMPEG_CONFIGURE+= --enable-version3
+  endif
+
+  ifeq ($(CONFIG_FFMPEG_CUSTOM_NONFREE),y)
+       FFMPEG_CONFIGURE+= --enable-nonfree
+  endif
+
   FFMPEG_CONFIGURE+= \
        --disable-programs \
        --disable-avfilter \
@@ -471,23 +498,32 @@ ifeq ($(CONFIG_FFMPEG_CUSTOM_SELECT_adpcm),y)
   FFMPEG_CONFIGURE+= \
        --enable-decoder=adpcm_ima_wav \
        --enable-decoder=adpcm_ima_qt \
-       --enable-decoder=adpcm_ms \
+       --enable-decoder=adpcm_ms
+endif
 
+ifeq ($(CONFIG_FFMPEG_CUSTOM_SELECT_libfdk-aac),y)
+  FFMPEG_CONFIGURE+= \
+       --enable-libfdk-aac --enable-encoder=libfdk_aac
+endif
+
+ifeq ($(CONFIG_FFMPEG_CUSTOM_SELECT_libmp3lame),y)
+  FFMPEG_CONFIGURE+= \
+       --enable-libmp3lame --enable-encoder=libmp3lame
 endif
 
 ifeq ($(CONFIG_FFMPEG_CUSTOM_SELECT_libopus),y)
   FFMPEG_CONFIGURE+= \
-       --enable-libopus --enable-decoder=libopus
+       --enable-libopus --enable-decoder=libopus --enable-encoder=libopus
 endif
 
-ifeq ($(CONFIG_FFMPEG_CUSTOM_SELECT_x264),y)
+ifeq ($(CONFIG_FFMPEG_CUSTOM_SELECT_libshine),y)
   FFMPEG_CONFIGURE+= \
-       --enable-libx264
+       --enable-libshine --enable-encoder=libshine
 endif
 
-ifeq ($(CONFIG_FFMPEG_CUSTOM_SELECT_mp3lame),y)
+ifeq ($(CONFIG_FFMPEG_CUSTOM_SELECT_libx264),y)
   FFMPEG_CONFIGURE+= \
-       --enable-libmp3lame
+       --enable-libx264 --enable-encoder=libx264
 endif
 
 endif
@@ -500,6 +536,9 @@ ifeq ($(BUILD_VARIANT),audio-dec)
        )
 
   FFMPEG_CONFIGURE+= \
+       --enable-small \
+       --enable-gpl \
+       \
        --disable-programs \
        --disable-avfilter \
        --disable-postproc \
@@ -508,7 +547,6 @@ ifeq ($(BUILD_VARIANT),audio-dec)
        --disable-everything \
        $(call FFMPEG_ENABLE,decoder,$(FFMPEG_AUDIO_DECODERS)) \
        $(call FFMPEG_ENABLE,demuxer,$(FFMPEG_AUDIO_DEMUXERS)) \
-       $(call FFMPEG_ENABLE,parser,$(FFMPEG_AUDIO_PARSERS)) \
        $(call FFMPEG_ENABLE,protocol,$(FFMPEG_AUDIO_PROTOCOLS)) \
        --disable-decoder=pcm_bluray,pcm_dvd \
 
@@ -522,6 +560,8 @@ ifeq ($(BUILD_VARIANT),mini)
        )
 
   FFMPEG_CONFIGURE+= \
+       --enable-small \
+       \
        --disable-programs \
        --disable-avdevice \
        --disable-avfilter \
@@ -531,12 +571,11 @@ ifeq ($(BUILD_VARIANT),mini)
        --disable-everything \
        $(call FFMPEG_ENABLE,decoder,$(FFMPEG_MINI_DECODERS)) \
        $(call FFMPEG_ENABLE,demuxer,$(FFMPEG_MINI_DEMUXERS)) \
-       $(call FFMPEG_ENABLE,protocol,$(FFMPEG_MINI_PROTOCOLS)) \
-
+       $(call FFMPEG_ENABLE,protocol,$(FFMPEG_MINI_PROTOCOLS))
 endif
 
 ifneq ($(CONFIG_TARGET_x86),)
-  TARGET_CFLAGS += -fomit-frame-pointer
+  TARGET_CFLAGS+= -fomit-frame-pointer
 endif
 
 define Build/Configure
@@ -558,13 +597,19 @@ define Build/InstallDev/custom
        $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/lib{avcodec,avdevice,avformat,avutil}.pc $(1)/usr/lib/pkgconfig/
 endef
 
+# Soft float is LGPL (no libpostproc); Hard float is GPL (yes libpostproc)
 define Build/InstallDev/full
        $(INSTALL_DIR) $(1)/usr/include
-       $(CP) $(PKG_INSTALL_DIR)/usr/include/lib{avcodec,avdevice,avfilter,avformat,avutil,postproc,swresample,swscale} $(1)/usr/include/
        $(INSTALL_DIR) $(1)/usr/lib
-       $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{avcodec,avdevice,avfilter,avformat,avutil,postproc,swresample,swscale}.{a,so*} $(1)/usr/lib/
        $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
-       $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/lib{avcodec,avdevice,avfilter,avformat,avutil,postproc,swresample,swscale}.pc $(1)/usr/lib/pkgconfig/
+       $(CP) $(PKG_INSTALL_DIR)/usr/include/lib{avcodec,avdevice,avfilter,avformat,avresample,avutil,swresample,swscale} $(1)/usr/include/
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{avcodec,avdevice,avfilter,avformat,avresample,avutil,swresample,swscale}.{a,so*} $(1)/usr/lib/
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/lib{avcodec,avdevice,avfilter,avformat,avresample,avutil,swresample,swscale}.pc $(1)/usr/lib/pkgconfig/
+ifneq ($(CONFIG_SOFT_FLOAT),y)
+       $(CP) $(PKG_INSTALL_DIR)/usr/include/libpostproc $(1)/usr/include/
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpostproc.{a,so*} $(1)/usr/lib/
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libpostproc.pc $(1)/usr/lib/pkgconfig/
+endif
 endef
 
 define Build/InstallDev/mini
@@ -622,9 +667,13 @@ define Package/libffmpeg-custom/install
        $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{avcodec,avdevice,avformat,avutil}.so.* $(1)/usr/lib/
 endef
 
+# Soft float is LGPL (no libpostproc); Hard float is GPL (yes libpostproc)
 define Package/libffmpeg-full/install
        $(INSTALL_DIR) $(1)/usr/lib
-       $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{avcodec,avdevice,avfilter,avformat,avutil,postproc,swresample,swscale}.so.* $(1)/usr/lib/
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{avcodec,avdevice,avfilter,avformat,avresample,avutil,swresample,swscale}.so.* $(1)/usr/lib/
+ifneq ($(CONFIG_SOFT_FLOAT),y)
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpostproc.so.* $(1)/usr/lib/
+endif
 endef
 
 define Package/libffmpeg-mini/install