From dbbf52ba4f089e654832fb9f78af9ffe73255e3d Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Tue, 30 Aug 2011 09:31:41 +0300 Subject: [PATCH] Rename ffmpeg-mt submodule to libav, delete non-mt/mt logic Rename the "ffmpeg-mt" submodule, which already contained Libav code, to the name "libav". Remove various code related to the earlier support for alternative FFmpeg and FFmpeg-mt submodules and switching between them. --- .gitignore | 6 +- .gitmodules | 7 +-- Makefile | 16 ++--- README | 62 ++++++------------- clean | 2 +- disable-mt | 34 ---------- enable-mt | 31 ---------- ffmpeg | 1 - init | 34 ++-------- ffmpeg-mt => libav | 0 script/export | 33 +++------- script/{ffmpeg-config => libav-config} | 14 ++--- script/update | 109 ++++++++++++++++++--------------- 13 files changed, 113 insertions(+), 236 deletions(-) delete mode 100755 disable-mt delete mode 100755 enable-mt delete mode 160000 ffmpeg rename ffmpeg-mt => libav (100%) rename script/{ffmpeg-config => libav-config} (82%) rewrite script/update (60%) diff --git a/.gitignore b/.gitignore index c244563..013f8d3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,9 @@ *.pyc /build_libs /common_options -/ffmpeg_options +/libav_options /mplayer_options -/ffmpeg_build -/ffmpeg-mt-enabled -/ffmpeg-mt-disabled +/libav_build # Debian package build creates random files under debian/. # Ignore the whole directory even though that will cause some problems. /debian diff --git a/.gitmodules b/.gitmodules index dea9e92..cf56411 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,12 +1,9 @@ -[submodule "ffmpeg"] - path = ffmpeg - url = git://repo.or.cz/FFMpeg-mirror/mplayer-patches.git [submodule "mplayer"] path = mplayer url = git://repo.or.cz/mplayer.git [submodule "libass"] path = libass url = git://repo.or.cz/libass.git -[submodule "ffmpeg-mt"] - path = ffmpeg-mt +[submodule "libav"] + path = libav url = git://repo.or.cz/FFMpeg-mirror/mplayer-patches.git diff --git a/Makefile b/Makefile index 9994e96..14d98f5 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,15 @@ -mplayer: ffmpeg libass +mplayer: libav libass script/mplayer-config $(MAKE) -C mplayer mplayer-config: script/mplayer-config -ffmpeg-config: - script/ffmpeg-config +libav-config: + script/libav-config -ffmpeg: ffmpeg-config - $(MAKE) -C ffmpeg_build install +libav: libav-config + $(MAKE) -C libav_build install libass-config: script/libass-config @@ -18,7 +18,7 @@ libass: libass-config $(MAKE) -C libass install noconfig: - $(MAKE) -C ffmpeg_build install + $(MAKE) -C libav_build install $(MAKE) -C libass install $(MAKE) -C mplayer @@ -26,8 +26,8 @@ install: $(MAKE) -C mplayer install clean: - -rm -rf ffmpeg_build + -rm -rf libav_build -$(MAKE) -C libass distclean -$(MAKE) -C mplayer distclean -.PHONY: mplayer-config mplayer ffmpeg-config ffmpeg libass-config libass noconfig install clean +.PHONY: mplayer-config mplayer libav-config libav libass-config libass noconfig install clean diff --git a/README b/README index 6f5f1ce..bbadf7c 100644 --- a/README +++ b/README @@ -1,10 +1,9 @@ -This repository contains scripts to help build MPlayer together with +This repository contains scripts to help build mplayer2 together with some dependencies that many platforms will not have a new enough version of. This makes it easy to compile the player against up-to-date library versions without needing to manually compile the -libraries first. More specifically, the scripts first compile FFmpeg -libraries and libass and then build the player statically linked -against those. +libraries first. More specifically, the scripts first compile Libav +and libass and then build the player statically linked against those. If you downloaded the tarball version of the repository then most of the sections below do not apply. In that case see only the @@ -12,10 +11,14 @@ following sections: "Prerequisites" "Basic use" (leave out the "./init" part, the tarball does not need that) "Building" -"Giving configure options to MPlayer and FFmpeg". - - -CHANGES FROM EARLIER VERSIONS OF THIS FILE (2010-12-20): +"Giving configure options to mplayer2 and Libav". + +CHANGES FROM EARLIER VERSIONS OF THIS FILE (2011-08-30): +Changed mentions of FFmpeg-mt/FFmpeg to Libav and removed the separate +documentation of threading. Libav has the threading support developed in +FFmpeg-mt, and mplayer2 uses a number of threads equal to CPU cores by +default. +(2010-12-20): FFmpeg-mt is now enabled by default in new installs (updating doesn't change selection), player selects thread count automatically @@ -29,7 +32,7 @@ addition to a basic build environment. The libass build system uses autotool packages (autoconf, automake, libtool). If you compile from git you must have those installed; tarball exports contain pregenerated files and those are not necessary. -FFmpeg needs the Yasm assembler. +Libav needs the Yasm assembler. Compiling with full features requires development files for several external libraries. Below is a list of some important requirements. @@ -70,42 +73,27 @@ or The latter form creates only partial git repositories which do not have full history data. This reduces the amount of data you need to download but reduces the development-related functionality of the -repositories. If you only want to simply build MPlayer it should +repositories. If you only want to simply build mplayer2 it should usually be enough. Building -You can build MPlayer with just 'make'. There is no separate -configure step because the MPlayer configure depends on included +You can build mplayer2 with just 'make'. There is no separate +configure step because the mplayer2 configure depends on included library sources being configured _and_ built first. If you want to give configuration options see the section below. -Enabling or disabling FFmpeg-mt - -FFmpeg-mt is version of FFmpeg with improved threading support, useful -for things like high-bitrate H264. It allows significantly faster -decoding on multicore machines. It is now enabled by default. -You can disable compilation with FFmpeg-mt decoders using "./disable-mt" -and enable it with "./enable-mt". By default MPlayer will try to determine -the number of cores available on your machine and use that as the number -of decoding threads. If you want to override that and use a different -number of threads you can use the "-lavdopts threads=N" option, -where N is the number of threads you want to use (a value equal to -the number of available cores is normally good). - +Giving configure options to mplayer2 and Libav - -Giving configure options to MPlayer and FFmpeg - -You can specify extra options that will be passed to MPlayer's +You can specify extra options that will be passed to mplayer2's configure script by placing them in a file called "mplayer_options" in -this directory. There's a corresponding file called "ffmpeg_options" -for FFmpeg. Options in file "common_options" will be passed to both -MPlayer and FFmpeg; this mainly makes sense for generic options like +this directory. There's a corresponding file called "libav_options" +for Libav. Options in file "common_options" will be passed to both +mplayer2 and Libav; this mainly makes sense for generic options like "-cc=gcc-4.4'. Place each option on its own line without any quoting. @@ -125,13 +113,3 @@ Download the latest version of the sources. Remove all generated or extra files from build directories and restore them to their original state. Running this between builds is probably a good idea. - -./enable-mt -./disable-mt -Enable or disable building with FFmpeg-mt support. Can be run before -first ./init or later to switch support on and off. The files -'ffmpeg-mt-enabled' and 'ffmpeg-mt-disabled' are created or deleted to -indicate whether -mt support is currently active. Note that if you -build MPlayer and then switch -mt support on or off, a rebuild is -likely to fail unless you remember to run ./clean before the new -build. diff --git a/clean b/clean index 99bd7b4..1f892d5 100755 --- a/clean +++ b/clean @@ -5,7 +5,7 @@ from script.helpers import GitWrapper def main(): git = GitWrapper() - check_call('rm -rf build_libs ffmpeg_build build-stamp configure-stamp'.split()) + check_call('rm -rf build_libs libav_build build-stamp configure-stamp'.split()) check_call('git clean -x -d -f debian/'.split()) def cmd(): check_call('git clean -x -d -f'.split()) diff --git a/disable-mt b/disable-mt deleted file mode 100755 index 9db95be..0000000 --- a/disable-mt +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python - -import os -import sys -from os import path -from subprocess import check_call - -from script.helpers import GitWrapper - -def main(): - print "Currently only ffmpeg-mt is supported." - sys.exit(1) - git = GitWrapper() - open('ffmpeg-mt-disabled', 'w').close() - if path.exists('ffmpeg-mt-enabled'): - os.remove('ffmpeg-mt-enabled') - # Allow setups where both ffmpeg and ffmpeg-mt are checked out - # simultaneously, and leave the directories alone in that case. - if path.exists('ffmpeg-mt/.git') and not path.exists('ffmpeg/.git'): - # ffmpeg should be an empty directory if things are right - os.rmdir('ffmpeg') - os.rename('ffmpeg-mt', 'ffmpeg') - os.mkdir('ffmpeg-mt') - if git.supports_nofetch: - cmd = 'git submodule update --no-fetch'.split() - else: - cmd = 'git submodule update'.split() - check_call(cmd + ['ffmpeg']) - os.chdir('ffmpeg') - def func(cmd=cmd): - check_call(cmd) - git.foreach_module(func) - -main() diff --git a/enable-mt b/enable-mt deleted file mode 100755 index c225e00..0000000 --- a/enable-mt +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python - -import os -from os import path -from subprocess import check_call - -from script.helpers import GitWrapper - -def main(): - git = GitWrapper() - open('ffmpeg-mt-enabled', 'w').close() - if path.exists('ffmpeg-mt-disabled'): - os.remove('ffmpeg-mt-disabled') - # Allow setups where both ffmpeg and ffmpeg-mt are checked out - # simultaneously, and leave the directories alone in that case. - if path.exists('ffmpeg/.git') and not path.exists('ffmpeg-mt/.git'): - # ffmpeg-mt should be an empty directory if things are right - os.rmdir('ffmpeg-mt') - os.rename('ffmpeg', 'ffmpeg-mt') - os.mkdir('ffmpeg') - if git.supports_nofetch: - cmd = 'git submodule update --no-fetch'.split() - else: - cmd = 'git submodule update'.split() - check_call(cmd + ['ffmpeg-mt']) - os.chdir('ffmpeg-mt') - def func(cmd=cmd): - check_call(cmd) - git.foreach_module(func) - -main() diff --git a/ffmpeg b/ffmpeg deleted file mode 160000 index 65e612b..0000000 --- a/ffmpeg +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 65e612b5943fe79a6aaf83c0f48a1e4a0f739ffc diff --git a/init b/init index b33f89a..e4318b0 100755 --- a/init +++ b/init @@ -20,17 +20,17 @@ mplayer_options = \ """ + option_helptext -ffmpeg_options = \ -"""# You can place options for FFmpeg configure in this file. +libav_options = \ +"""# You can place options for Libav configure in this file. """ + option_helptext common_options = \ -"""# You can place options common for both MPlayer and FFmpeg configure in +"""# You can place options common for both MPlayer and Libav configure in # this file. This mainly makes sense for generic things like --cc. # # NOTE: Several people used --prefix here for some reason. Don't do that! -# The internal FFmpeg library created during the build is installed under +# The internal Libav library created during the build is installed under # the build tree by default and should not be placed anywhere else! # If you want to specify a custom location for the final install that # should be done in mplayer_options. @@ -57,39 +57,17 @@ def main(): sys.exit(1) create_helpfile('mplayer_options', mplayer_options) - create_helpfile('ffmpeg_options', ffmpeg_options) + create_helpfile('libav_options', libav_options) create_helpfile('common_options', common_options) if opts.init_optionfiles_only: return - # If this looks like a new install enable FFmpeg-mt by default. - # The ffmpeg/.git check is to catch updates from old versions with no - # explicit ffmpeg-mt-disabled. - if not path.exists('ffmpeg-mt-enabled') \ - and not path.exists('ffmpeg-mt-disabled') \ - and not path.exists('ffmpeg/.git'): - open('ffmpeg-mt-enabled', 'w').close() - git = GitWrapper() git.shallow = opts.shallow check_call('git submodule init'.split()) git.submodule_clone('mplayer') - if path.exists('ffmpeg-mt-enabled'): - git.submodule_clone('ffmpeg-mt') - else: - git.submodule_clone('ffmpeg') + git.submodule_clone('libav') git.submodule_clone('libass') - # Ensure sync, needed in addition what's done in submodule_clone() above - # at least if both ffmpeg and ffmpeg-mt dirs exist separately - def cmd(): - check_call('git submodule sync'.split()) - git.foreach_module(cmd) - # Init recursive submodules (libswscale under ffmpeg) - not trying to - # make this support shallow clones for now. - def cmd(): - check_call('git submodule update --init'.split()) - git.foreach_submodule(cmd) - main() diff --git a/ffmpeg-mt b/libav similarity index 100% rename from ffmpeg-mt rename to libav diff --git a/script/export b/script/export index 3774ae9..ec0083c 100755 --- a/script/export +++ b/script/export @@ -4,59 +4,46 @@ import os from helpers import run_command from optparse import OptionParser -def write(local_path, path, revision, outdir): - if os.system("(cd %s && git archive --format=tar --prefix=%s/ %s | (cd %s && tar xf -))" % (local_path, path, revision, outdir)) != 0: +def write(path, revision, outdir): + if os.system("(cd %s && git archive --format=tar --prefix=%s/ %s | (cd %s && tar xf -))" % (path, path, revision, outdir)) != 0: raise OSError def subrev(revision, name): return run_command(("git", "ls-tree", revision, name)).split()[2] -def export(revision, outdir, mt): +def export(revision, outdir): os.mkdir(outdir) - if mt: - ffmpeg = "ffmpeg-mt" - open(outdir + '/ffmpeg-mt-enabled', 'w').close() - else: - ffmpeg = "ffmpeg" - open(outdir + '/ffmpeg-mt-disabled', 'w').close() - if os.path.exists('ffmpeg-mt-enabled'): - local_ffmpeg = 'ffmpeg-mt' - else: - local_ffmpeg = 'ffmpeg' mplayer_rev = subrev(revision, "mplayer") libass_rev = subrev(revision, "libass") - ffmpeg_rev = subrev(revision, ffmpeg) + libav_rev = subrev(revision, "libav") os.chdir('mplayer') version = run_command('git describe --match v[0-9]* --always ' + mplayer_rev).strip() os.chdir('..') - write('.', '.', revision, outdir) + write('.', revision, outdir) os.putenv('PYTHONDONTWRITEBYTECODE', '1') os.system("cd %s && ./init --init-optionfiles-only" % outdir) - for name in 'clean disable-mt enable-mt init update'.split(): + for name in 'clean init update'.split(): os.remove(outdir + '/' + name) numeric_rev = run_command('git rev-parse ' + revision) f = open(outdir + '/wrapper_export_version', 'w') f.write(numeric_rev) f.close() - write('mplayer', "mplayer", mplayer_rev, outdir) + write('mplayer', mplayer_rev, outdir) f = open(outdir + '/mplayer/snapshot_version', 'w') f.write(version) f.close() - write('libass', "libass", libass_rev, outdir) + write('libass', libass_rev, outdir) os.system("cd %s/libass && autoreconf -ivf" % outdir) - write(local_ffmpeg, ffmpeg, ffmpeg_rev, outdir) + write('libav', libav_rev, outdir) def main(): usage = "usage: [options] revision outdir" parser = OptionParser(usage=usage) - parser.add_option('--disable-mt', action='store_false', dest="mt", - help='use non-mt FFmpeg') - parser.set_defaults(mt=True) options, args = parser.parse_args() if len(args) != 2: parser.error("incorrect number of arguments") - export(args[0], args[1], options.mt) + export(args[0], args[1]) main() diff --git a/script/ffmpeg-config b/script/libav-config similarity index 82% rename from script/ffmpeg-config rename to script/libav-config index 036600a..5fc2fd5 100755 --- a/script/ffmpeg-config +++ b/script/libav-config @@ -8,17 +8,17 @@ from subprocess import check_call def main(): try: - os.mkdir('ffmpeg_build') + os.mkdir('libav_build') except: pass mydir = os.getcwd() extra_args = parse_configfile('common_options') - for arg in parse_configfile('ffmpeg_options'): + for arg in parse_configfile('libav_options'): if arg == 'librtmp_magic': try: check_call('pkg-config --exists librtmp'.split()) except: - sys.exit('You have specified "librtmp_magic" in ffmpeg_options,' + sys.exit('You have specified "librtmp_magic" in libav_options,' 'but running "pkg-config --exists librtmp" failed - ' "can't enable librtmp! Aborting.") extra_args.append('--enable-librtmp') @@ -40,13 +40,9 @@ def main(): '--disable-avplay', '--disable-avserver','--disable-avprobe', '--disable-vaapi'] - if os.path.exists('ffmpeg-mt-enabled'): - ffmpeg_dir = 'ffmpeg-mt' - else: - ffmpeg_dir = 'ffmpeg' - executable = path.join(mydir, ffmpeg_dir, 'configure') + executable = path.join(mydir, 'libav', 'configure') - os.chdir('ffmpeg_build') + os.chdir('libav_build') check_call([executable] + args + extra_args) main() diff --git a/script/update b/script/update dissimilarity index 60% index 6a55a40..96b8ed9 100755 --- a/script/update +++ b/script/update @@ -1,50 +1,59 @@ -#!/usr/bin/env python - -import os -from os import path -from subprocess import check_call - -from helpers import GitWrapper, run_command - -def main(): - git = GitWrapper() - - # Currently only ffmpeg-mt is supported. When upgrading from - # previous versions force it enabled. - switch_to_mt = not path.exists('ffmpeg-mt-enabled') - if switch_to_mt: - open('ffmpeg-mt-enabled', 'w').close() - if path.exists('ffmpeg-mt-disabled'): - os.remove('ffmpeg-mt-disabled') - # Allow setups where both ffmpeg and ffmpeg-mt are checked out - # simultaneously, and leave the directories alone in that case. - if path.exists('ffmpeg/.git') and not path.exists('ffmpeg-mt/.git'): - # fmpeg-mt should be an empty directory if things are right - os.rmdir('ffmpeg-mt') - os.rename('ffmpeg', 'ffmpeg-mt') - os.mkdir('ffmpeg') - # libswscale has changed from a submodule to a normal subdirectory - if path.exists('ffmpeg-mt/libswscale/.git'): - os.system('cd ffmpeg-mt && rm -rf libswscale') - - config = git.get_config() - submodules = git.get_submodules() - # Update existing submodules, but don't check out new ones - for p in submodules: - if not 'submodule.%s.url' % p in config: - continue - if not path.exists(path.join(p, '.git')): - continue - check_call('git submodule update'.split() + [p]) - def cmd(): - check_call('git submodule update --init'.split()) - git.foreach_submodule(cmd) - - if switch_to_mt: - print - print "Currently only ffmpeg-mt version is maintained." - print "This repository has been automatically switched from ffmpeg to ffmpeg-mt." - print "This should work OK on single-core machines too." - print "You should run ./clean before recompiling due to the switch." - -main() +#!/usr/bin/env python + +import os +from os import path +from subprocess import check_call + +from helpers import GitWrapper, run_command + +def main(): + git = GitWrapper() + + # Update from versions using a submodule name different from "libav" + p = None + if path.exists('ffmpeg-mt/.git'): + p = 'ffmpeg-mt' + else: + p = 'ffmpeg' + switch_to_libav = not path.exists('libav/.git') and p + if switch_to_libav: + if p == 'ffmpeg-mt' and path.exists('ffmpeg-mt/libswscale/.git'): + # Update from old version with libswscale as submodule + os.system('cd ffmpeg-mt && rm -rf libswscale') + os.rename(p, 'libav') + try: + # Rename the build dir mainly to get it cleaned up - + # incremental builds probably won't work due to wrong absolute + # paths recorded in .d files. + os.rename('ffmpeg_build', 'libav_build') + except: + pass + if path.exists('ffmpeg_options') and not path.exists('libav_options'): + os.rename('ffmpeg_options', 'libav_options') + for fname in ('ffmpeg-mt-enabled', 'ffmpeg-mt-disabled'): + if path.exists(fname): + os.remove(fname) + check_call('git submodule init libav'.split()) + + config = git.get_config() + submodules = git.get_submodules() + # Update existing submodules, but don't check out new ones + for p in submodules: + if not 'submodule.%s.url' % p in config: + continue + if not path.exists(path.join(p, '.git')): + continue + check_call('git submodule update'.split() + [p]) + def cmd(): + check_call('git submodule update --init'.split()) + git.foreach_submodule(cmd) + + if switch_to_libav: + print + print "The ffmpeg-mt submodule directory has been renamed to libav." + print "The contents of the submodule have already been based on" + print "the Libav project for some time (FFmpeg-mt was merged to it)." + print "The ffmpeg_options file has been renamed to libav_options." + print "You should run ./clean before recompiling due to the switch." + +main() -- 2.11.4.GIT