Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Makefile(s): add proper libmfx support (including static build)
  • Loading branch information
perexg committed Sep 29, 2015
1 parent 5fd66bf commit a6f264a
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 18 deletions.
9 changes: 9 additions & 0 deletions Makefile
Expand Up @@ -85,6 +85,13 @@ LDFLAGS += -lx265
endif
endif
LDFLAGS += ${LDFLAGS_FFDIR}/libvpx.a
ifeq ($(CONFIG_LIBMFX),yes)
ifeq ($(CONFIG_LIBMFX_STATIC),yes)
LDFLAGS += ${LDFLAGS_FFDIR}/libmfx.a -lstdc++ -lva-drm -lva
else
LDFLAGS += -lmfx
endif
endif
endif

ifeq ($(CONFIG_HDHOMERUN_STATIC),yes)
Expand Down Expand Up @@ -652,6 +659,8 @@ ${ROOTDIR}/libav_static/build/ffmpeg/lib/libavcodec.a: Makefile.ffmpeg
CONFIG_LIBX264_STATIC=$(CONFIG_LIBX264_STATIC) \
CONFIG_LIBX265=$(CONFIG_LIBX265) \
CONFIG_LIBX265_STATIC=$(CONFIG_LIBX265_STATIC) \
CONFIG_LIBMFX=$(CONFIG_LIBMFX) \
CONFIG_LIBMFX_STATIC=$(CONFIG_LIBMFX_STATIC) \
$(MAKE) -f Makefile.ffmpeg build

# Static HDHOMERUN library
Expand Down
66 changes: 48 additions & 18 deletions Makefile.ffmpeg
Expand Up @@ -52,6 +52,7 @@ export PATH := $(LIBAVDIR)/build/ffmpeg/bin:$(PATH)
ECFLAGS = -I$(LIBAVDIR)/build/ffmpeg/include
ELIBS = -L$(LIBAVDIR)/build/ffmpeg/lib -ldl

EXTRAENV =
CONFIGURE = TVHEADEND_LIBAV_BUILD=$(LIBAVDIR)/ffmpeg \
PKG_CONFIG=$(ROOTDIR)/support/pkg-config.ffmpeg ./configure

Expand Down Expand Up @@ -98,11 +99,11 @@ YASM_TB = $(YASM).tar.gz
YASM_URL = http://www.tortall.net/projects/yasm/releases/$(YASM_TB)
YASM_SHA1 = b7574e9f0826bedef975d64d3825f75fbaeef55e

MFXDIS_HASH = 1582088ee7670ab1c96cefe844d9647274c0c841
MFXDIS = mfx_dispatch-$(MFXDIS_HASH)
MFXDIS_TB = $(MFXDIS_HASH).tar.gz
MFXDIS_URL = https://github.com/lu-zero/mfx_dispatch/archive/$(MFXDIS_TB)
MFXDIS_SHA1 = 5a1f0cab45d675eb6a29f3dd38676f1e343e6ef1
LIBMFX_HASH = 1582088ee7670ab1c96cefe844d9647274c0c841
LIBMFX = mfx_dispatch-$(LIBMFX_HASH)
LIBMFX_TB = $(LIBMFX_HASH).tar.gz
LIBMFX_URL = https://github.com/lu-zero/mfx_dispatch/archive/$(LIBMFX_TB)
LIBMFX_SHA1 = 5a1f0cab45d675eb6a29f3dd38676f1e343e6ef1


.PHONY: build
Expand All @@ -111,7 +112,6 @@ build: $(LIBAVDIR)/$(FFMPEG)/.tvh_build
#
# YASM
#

$(LIBAVDIR)/$(YASM)/.tvh_download:
$(call DOWNLOAD,$(YASM_URL),$(LIBAVDIR)/$(YASM_TB),$(YASM_SHA1))
$(call UNTAR,$(YASM_TB),z)
Expand All @@ -126,25 +126,52 @@ $(LIBAVDIR)/$(YASM)/.tvh_build: \
@touch $@

#
# MFX Dispatcher
# MFX Dispatcher (libmfx)
#

$(LIBAVDIR)/$(MFXDIS)/.tvh_download:
$(call DOWNLOAD,$(MFXDIS_URL),$(LIBAVDIR)/$(MFXDIS_TB),$(MFXDIS_SHA1))
$(call UNTAR,$(MFXDIS_TB),z)
ifeq (yes,$(CONFIG_LIBMFX))

EXTLIBS += libmfx

DECODERS += mpeg2_qsv h264_qsv hevc_qsv
ENCODERS += mpeg2_qsv h264_qsv hevc_qsv

endif

ifeq (yes,$(CONFIG_LIBMFX_STATIC))

$(LIBAVDIR)/$(LIBMFX)/.tvh_download:
$(call DOWNLOAD,$(LIBMFX_URL),$(LIBAVDIR)/$(LIBMFX_TB),$(LIBMFX_SHA1))
$(call UNTAR,$(LIBMFX_TB),z)
@touch $@

$(LIBAVDIR)/$(MFXDIS)/.tvh_build: \
$(LIBAVDIR)/$(MFXDIS)/.tvh_download
cd $(LIBAVDIR)/$(MFXDIS) && libtoolize --force --copy --automake
cd $(LIBAVDIR)/$(MFXDIS) && aclocal
cd $(LIBAVDIR)/$(MFXDIS) && automake --foreign --copy --add-missing
cd $(LIBAVDIR)/$(MFXDIS) && $(CONFIGURE) \
$(LIBAVDIR)/$(LIBMFX)/.tvh_build: \
$(LIBAVDIR)/$(LIBMFX)/.tvh_download
cd $(LIBAVDIR)/$(LIBMFX) && autoreconf -i
cd $(LIBAVDIR)/$(LIBMFX) && ./configure \
--with-libva_drm \
--prefix=/ffmpeg
DESTDIR=$(LIBAVDIR)/build \
$(MAKE) -C $(LIBAVDIR)/$(MFXDIS) install
$(MAKE) -C $(LIBAVDIR)/$(LIBMFX) install
@touch $@

else

LIBMFX_CFLAGS = $(shell $(PKG_CONFIG) --cflags libmfx)
LIBMFX_LIBS = $(shell $(PKG_CONFIG) --libs libmfx)

EXTRAENV += TVHEADEND_LIBMFX_CFLAGS="$(LIBMFX_CFLAGS)" TVHEADEND_LIBMFX_LIBS="$(LIBMFX_LIBS)"

$(LIBAVDIR)/$(LIBMFX)/.tvh_download:
@mkdir -p $(LIBAVDIR)/$(LIBMFX)
@touch $@

$(LIBAVDIR)/$(LIBMFX)/.tvh_build: \
$(LIBAVDIR)/$(LIBMFX)/.tvh_download
@touch $@

endif

#
# libogg & libvorbis
#
Expand Down Expand Up @@ -240,6 +267,8 @@ endif

ifeq (yes,$(CONFIG_LIBX265_STATIC))

ELIBS += -lva-drm -lva

$(LIBAVDIR)/$(LIBX265)/.tvh_download:
$(call DOWNLOAD,$(LIBX265_URL),$(LIBAVDIR)/$(LIBX265_TB),$(LIBX265_SHA1))
$(call UNTAR,$(LIBX265_TB),z)
Expand Down Expand Up @@ -305,8 +334,9 @@ $(LIBAVDIR)/$(FFMPEG)/.tvh_build: \
$(LIBAVDIR)/$(LIBX264)/.tvh_build \
$(LIBAVDIR)/$(LIBX265)/.tvh_build \
$(LIBAVDIR)/$(LIBVPX)/.tvh_build \
$(LIBAVDIR)/$(LIBMFX)/.tvh_build \
$(LIBAVDIR)/$(FFMPEG)/.tvh_download
cd $(LIBAVDIR)/$(FFMPEG) && $(CONFIGURE) \
cd $(LIBAVDIR)/$(FFMPEG) && $(EXTRAENV) $(CONFIGURE) \
--prefix=/ffmpeg \
--disable-all \
--enable-static \
Expand Down
8 changes: 8 additions & 0 deletions configure
Expand Up @@ -38,6 +38,8 @@ OPTIONS=(
"libx264_static:yes"
"libx265:no"
"libx265_static:yes"
"libmfx:no"
"libmfx_static:no"
"inotify:auto"
"epoll:auto"
"uriparser:auto"
Expand Down Expand Up @@ -397,6 +399,12 @@ if enabled libffmpeg_static; then
disable libx265_static
fi

# libmfx
if enabled libmfxdis; then
check_cc_lib libva-drm || die "libva-drm not found"
check_cc_lib mfx || die "libmfx not found"
fi

else

if enabled_or_auto libav; then
Expand Down
1 change: 1 addition & 0 deletions support/configure.inc
Expand Up @@ -485,6 +485,7 @@ GZIPCMD ?= ${GZIPCMD}
BZIP2 ?= ${BZIP2}
XGETTEXT ?= ${XGETTEXT}
MSGMERGE ?= ${MSGMERGE}
PKG_CONFIG ?= ${PKG_CONFIG}
CFLAGS += ${CFLAGS}
LDFLAGS += ${LDFLAGS}
prefix = ${prefix}
Expand Down
9 changes: 9 additions & 0 deletions support/pkg-config.ffmpeg
Expand Up @@ -39,6 +39,15 @@ x265)
cflags_="-I$TVHEADEND_LIBAV_BUILD/include"
libs_="-L$TVHEADEND_LIBAV_BUILD/lib -lx265 -lstdc++"
;;
libmfx)
if test -z "$TVHEADEND_LIBMFX_CFLAGS" -a -z "$TVHEADEND_LIBMFX_LIBS"; then
cflags_="-I$TVHEADEND_LIBAV_BUILD/include"
libs_="-L$TVHEADEND_LIBAV_BUILD/lib -lmfx -lstdc++"
else
cflags_="$TVHEADEND_LIBMFX_CFLAGS"
libs_="$TVHEADEND_LIBMFX_LIBS"
fi
;;
esac

case "$cmd" in
Expand Down

0 comments on commit a6f264a

Please sign in to comment.