SSブログ

各種コーディックのインストール - opencode-amr 編 - [FreeBSD]

ライブラリopencode-amr
公式ページhttp://sourceforge.net/projects/opencore-amr/

AMRは、DoCoMoのFORMで着うたのファイルフォーマットとして使用されているものです。
AMRは、AMR-NBとAMR-WBがありますが、opencode-amrは、両方のライブラリを含んでいます。
FreeBSDのportsには、見つからなかったので、ソースよりコンパイルし、インストールします。

●準備
公式ページよりアーカイブを取得し、解凍します。


●./configure
解凍したディレクトリに移動し、./configureでコンパイルオプションを指定します。
./configure --helpでオプションを確認しても特に指定するオプションが無かったため、
オプションなしで実行します。
> cd opencore-amr-0.1.2
> ./configure



checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking for memset... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating amrnb/Makefile
config.status: creating amrwb/Makefile
config.status: creating test/Makefile
config.status: creating amrnb/opencore-amrnb.pc
config.status: creating amrwb/opencore-amrwb.pc
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands

特に問題なく終了しました。

●コンパイル
コンパイルします。
> make



libtool: link: gcc -g -O2 -o .libs/amrnb-enc amrnb-enc.o ../amrnb/.libs/libopencore-amrnb.so -lm -Wl,-rpath -Wl,/usr/local/lib
g++ -DHAVE_CONFIG_H -I. -I.. -I../amrnb -I../amrwb -g -O2 -MT amrwb-dec.o -MD -MP -MF .deps/amrwb-dec.Tpo -c -o amrwb-dec.o amrwb-dec.cpp
mv -f .deps/amrwb-dec.Tpo .deps/amrwb-dec.Po
/bin/sh ../libtool --tag=CXX --mode=link g++ -g -O2 -o amrwb-dec amrwb-dec.o wav.o ../amrwb/libopencore-amrwb.la -lm
libtool: link: g++ -g -O2 -o .libs/amrwb-dec amrwb-dec.o wav.o ../amrwb/.libs/libopencore-amrwb.so -lm -Wl,-rpath -Wl,/usr/local/lib
gcc -DHAVE_CONFIG_H -I. -I.. -I../amrnb -I../amrwb -g -O2 -MT linkboth.o -MD -MP -MF .deps/linkboth.Tpo -c -o linkboth.o linkboth.c
mv -f .deps/linkboth.Tpo .deps/linkboth.Po
/bin/sh ../libtool --tag=CC --mode=link gcc -g -O2 -static -o linkboth linkboth.o ../amrnb/libopencore-amrnb.la ../amrwb/libopencore-amrwb.la -lm
libtool: link: gcc -g -O2 -o linkboth linkboth.o ../amrnb/.libs/libopencore-amrnb.a ../amrwb/.libs/libopencore-amrwb.a -lm

これも特に問題なく終了しました。今回は、なんだか順調です。

チェック用のスクリプトが用意されているので、チェックします。
> make check
Making check in amrnb
Making check in amrwb
Making check in test

成功か失敗かよくわからないメッセージが表示されましたが、
エラーメッセージでは無いようなので、成功にしておきます。

rootになって、インストールします。
> su # make install



----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,-rpath -Wl,LIBDIR' linker flag

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
test -z "/usr/local/include/opencore-amrwb" || .././install-sh -c -d "/usr/local/include/opencore-amrwb"
/usr/bin/install -c -m 644 dec_if.h if_rom.h '/usr/local/include/opencore-amrwb'
test -z "/usr/local/lib/pkgconfig" || .././install-sh -c -d "/usr/local/lib/pkgconfig"
/usr/bin/install -c -m 644 opencore-amrwb.pc '/usr/local/lib/pkgconfig'
Making install in test

無事インストールされました。
今回は、特に躓く箇所も無く、素直にインストールできました。
なんだか、ちょっと拍子抜けです。


各種コーディックのインストール - Theora編 - [FreeBSD]

ライブラリtheora
公式ページhttp://www.theora.org/

theoraは、Oggコンテナフォーマットの標準ビデオコーディックてして利用されるものです。
あまり利用する機会は無いような気がしますが、とりあえずインストールしておきます。
portsでは、バージョンが1.0だったので、最新バージョン1.1.1を公式ページより
取得してソースよりコンパイルします。

●準備
公式ページよりアーカイブを取得し、解凍します。
> fetch http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.bz2
> bzip2 -d libtheora-1.1.1.tar.bz2
> tar zxvf libtheora-1.1.1.tar

●./configure
解凍したディレクトリに移動し、./configureでコンパイルオプションを指定します。
./configure --helpでオプションを確認しても特に指定するオプションが無かったため、
オプションなしで実行します。
> cd libtheora-1.1.1
> ./configure

sdl-config が無いと怒られたので、portsよりインストールします。

アプリportsの場所
sdl-config/usr/ports/devel/sdl12

オプションを聞かれるので、デフォルトにします。
> cd /usr/ports/devel/sdl12
> su
# make
# make install
# make clean

再度、libtheoraを解凍したディレクトリに戻って、./configureを実行します。
> cd libtheora-1.1.1
> ./configure



------------------------------------------------------------------------
libtheora 1.1.1: Automatic configuration OK.

General configuration:

Encoding support: ........... yes
Floating point support: ..... yes
Assembly optimization: ...... no optimization for your platform, please send a patch
Debugging telemetry: ........ no
Build example code: ......... yes
API Documentation: .......... no
Format Documentation: ....... no

Installation paths:

libtheora: ................... /usr/local/lib
C header files: .............. /usr/local/include/theora
Documentation: ............... /usr/local/share/doc/libtheora

Building:

Type 'make' to compile libtheora.

Type 'make install' to install libtheora.

Type 'make check' to run test suite (Valgrind testing not enabled)

Example programs will be built but not installed.
------------------------------------------------------------------------

特に問題なく終了しました。
●コンパイル
メッセージどおりコンパイルします。
> make



source='dump_video.c' object='dump_video.o' libtool=no depfile='.deps/dump_video.Po' tmpdepfile='.deps/dump_video.TPo' depmode=gcc3 /bin/sh ../depcomp gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../include -I/usr/local/include -Wall -Wno-parentheses -O3 -fforce-addr -fomit-frame-pointer -finline-functions -funroll-loops -c `test -f 'dump_video.c' || echo './'`dump_video.c
In file included from dump_video.c:43:
/usr/include/sys/timeb.h:43: error: expected specifier-qualifier-list before 'time_t'
dump_video.c: In function 'main':
dump_video.c:448: error: 'struct timeb' has no member named 'time'
dump_video.c:448: error: 'struct timeb' has no member named 'millitm'
dump_video.c:449: error: 'struct timeb' has no member named 'time'
dump_video.c:449: error: 'struct timeb' has no member named 'millitm'
dump_video.c:456: error: 'struct timeb' has no member named 'time'
dump_video.c:456: error: 'struct timeb' has no member named 'millitm'
dump_video.c:457: error: 'struct timeb' has no member named 'time'
dump_video.c:457: error: 'struct timeb' has no member named 'millitm'
*** Error code 1

Stop in /usr/local/home/hideki/build.d/libtheora-1.1.1/examples.
*** Error code 1

Stop in /usr/local/home/hideki/build.d/libtheora-1.1.1.
*** Error code 1

Stop in /usr/local/home/hideki/build.d/libtheora-1.1.1.

うーん、エラー発生です。timeb.hで使用されているtime_tが定義されていない為、エラーとなっているようです。
time_tは、/usr/include/time.hに定義されていますが、exsamples/dump_video.cには、インクルードされていないようです。
#include の前に、#include を追加します。
> vi exsamples/dump_video.c



#include
#include
#include <--- これを追加
#include
#include




再度make
> make



source='player_example.c' object='player_example-player_example.o' libtool=no depfile='.deps/player_example-player_example.Po' tmpdepfile='.deps/player_example-player_example.TPo' depmode=gcc3 /bin/sh ../depcomp gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../include -I/usr/local/include/SDL -I/usr/local/include -D_GNU_SOURCE=1 -D_REENTRANT -I/usr/local/include -I/usr/local/include -Wall -Wno-parentheses -O3 -fforce-addr -fomit-frame-pointer -finline-functions -funroll-loops -c -o player_example-player_example.o `test -f 'player_example.c' || echo './'`player_example.c
player_example.c:68:31: error: machine/soundcard.h: No such file or directory
player_example.c: In function 'open_audio':
player_example.c:166: error: 'audio_buf_info' undeclared (first use in this function)
player_example.c:166: error: (Each undeclared identifier is reported only once
player_example.c:166: error: for each function it appears in.)
player_example.c:166: error: expected ';' before 'info'
player_example.c:167: error: 'AFMT_S16_NE' undeclared (first use in this function)
player_example.c:178: error: 'SNDCTL_DSP_SETFMT' undeclared (first use in this function)
player_example.c:184: error: 'SNDCTL_DSP_CHANNELS' undeclared (first use in this function)
player_example.c:190: error: 'SNDCTL_DSP_SPEED' undeclared (first use in this function)
player_example.c:196: error: 'SNDCTL_DSP_GETOSPACE' undeclared (first use in this function)
player_example.c:196: error: 'info' undeclared (first use in this function)
player_example.c: In function 'audio_close':
player_example.c:205: error: 'SNDCTL_DSP_RESET' undeclared (first use in this function)
player_example.c: In function 'audio_write_nonblocking':
player_example.c:275: error: 'audio_buf_info' undeclared (first use in this function)
player_example.c:275: error: expected ';' before 'info'
player_example.c:278: error: 'SNDCTL_DSP_GETOSPACE' undeclared (first use in this function)
player_example.c:278: error: 'info' undeclared (first use in this function)
*** Error code 1

Stop in /usr/local/home/hideki/build.d/libtheora-1.1.1/examples.
*** Error code 1

Stop in /usr/local/home/hideki/build.d/libtheora-1.1.1.
*** Error code 1

Stop in /usr/local/home/hideki/build.d/libtheora-1.1.1.
また、エラー。 今度は、machine/soundcard.hが無いと怒られました。 examples/player_example.c を見てみると、以下のように、FreeBSD用にインクルードされています。
> cat examples/player_example.c



#if defined(__FreeBSD__)
#include
#define AUDIO_DEVICE "/dev/audio"
#elif defined(__NetBSD__) || defined(__OpenBSD__)



ここで、インクルードされているmachine/soundcard.hは、 FreeBSD 8.0では、sys/soundcard.h に存在しているので、 書き換えます。
> vi examples/player_example.c



#if defined(__FreeBSD__)
#include <-- ここを書き換え
#define AUDIO_DEVICE "/dev/audio"
#elif defined(__NetBSD__) || defined(__OpenBSD__)



再度 makeするとコンパイルが通ったので、make installでインストールします。
> make
> make install
テストスクリプトもあるようなので、実行します。
> make check



PASS: granulepos_theoraenc
---- + Checking granulepos generation ...
---- + Checking granulepos generation ...
---- + Checking granulepos generation ...
---- + Checking granulepos generation ...
---- + Checking granulepos generation ...
---- + Checking granulepos generation ...
PASS: granulepos_theora
==================
All 9 tests passed
==================
Making check in m4
Making check in examples
すべてのテストは、無事成功しました。 それにしても、素直にソースからコンパイルできるものは、なかなか無いものですね。

各種コーディックのインストール - x264編 - [FreeBSD]

ライブラリx264
公式ページhttp://www.videolan.org/developers/x264.html

H.264のエンコード、デコードを行うライブラリx264は、
ソースの更新頻度が高く、snapshotが毎日作成され公開されています。
FreeBSDのportsでは、2008年12月頃のバージョンで少々古い為、
最新版を取得して、導入します。

●準備
公開リポジトリからソースを取得する為に、gitやsvnといったツールを
portsよりインストールします。オプションを聞いてくるので、デフォルトで入れます。
アプリportsの場所
git/usr/ports/devel/git
svn/usr/ports/devel/svn

gitを使用して、最新ソースを取得します。
> git clone git://git.videolan.org/x264.git

●./configure
Unix系の大抵のアプリケーションやライブラリは、configureスクリプトで各種オプションを指定し、makeでコンパイル、make installでインストールできます。
x264も例外ではなく、この手順で導入できます。

まずは、指定できるオプションを確認。
>./configure --help
Usage: ./configure [options]

available options:

--help print this message
--disable-avis-input disables avisynth input (win32 only)
--disable-mp4-output disables mp4 output (using gpac)
--disable-pthread disables multithreaded encoding
--disable-asm disables assembly optimizations on x86 and arm
--enable-debug adds -g, doesn't strip
--enable-gprof adds -pg, doesn't strip
--enable-visualize enables visualization (X11 only)
--enable-pic build position-independent code
--enable-shared build libx264.so
--extra-asflags=EASFLAGS add EASFLAGS to ASFLAGS
--extra-cflags=ECFLAGS add ECFLAGS to CFLAGS
--extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS
--host=HOST build programs to run on HOST
--cross-prefix=PREFIX use PREFIX for compilation tools

libx264.soを作成したいので、オプションに--enable-sharedを付けて実行。
>./configure --enable-shared
./configure: Command not found.

ファイルの存在、スペルの打ち間違い、パーミッションを調べても異常なし。
configureの中を見てみると、シェルにbashを使用していました。
> cat ./configure | more
#!/bin/bash
if test x"$1" = x"-h" -o x"$1" = x"--help" ; then

echo "Usage: ./configure [options]"
echo ""
echo "available options:"
echo ""
echo " --help print this message"




bashをportsを使用してインストールします。
アプリportsの場所
bash/usr/ports/shells/bash

/usr/local/binにインストールされるので、/binにシンボリックリンクを作ります。
ln -s /usr/local/bin/bash /bin/bash

再度、チャレンジ
>./configure --enable-shared
Found GNU assembler 2.15 [FreeBSD] 2004-05-23
Minimum version is binutils-2.17
Your compiler can't handle inline SSSE3 asm.
If you really want to compile without asm, configure with --disable-asm.

binutilsがバージョン2.15と古いので、SSSE3を有効にするなら、2.17以上にする必要があるようです。
portsよりインストールします。portsでインストールされるバージョンは、2.20です。
アプリportsの場所
bash/usr/ports/devel/binutils

x264でチェックしているのは、asコマンドのバージョンです。
デフォルトのもの(2.15)は、/usr/binにインストールされており、
portsでインストールしたもの(2.20)は、/usr/local/binにインストールされます。
参照の順番で/usr/binが先に参照されてしまうので、/usr/bin/asをリネームして/usr/local/bin/asへのシンボリックリンクを作成します。
# mv /usr/bin/as /usr/bin/as.2.15
# ln -s /usr/local/bin/as /usr/bin/as

再度チャレンジ
>./configure --enable-shared
Platform: X86_64
System: FREEBSD
asm: yes
avis input: no
mp4 output: no
pthread: yes
debug: no
gprof: no
PIC: yes
shared: yes
visualize: no

You can run 'make' or 'make fprofiled' now.

mp4 outputが有効になっていません。
./configure --helpでは、using gpac と記述されているので、gpacをportsからインストールします。
アプリportsの場所
gpac/usr/ports/multimedia/gpac-libgpac

gpacのライブラリ及びインクルードファイルは、/usr/local/libと/usr/local/includeにインストールされます。
そのため、./configureにて、これらを参照するようにオプションを追加します。
> ./configure --enable-shared --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib
Platform: X86_64
System: FREEBSD
asm: yes
avis input: no
mp4 output: yes
pthread: yes
debug: no
gprof: no
PIC: yes
shared: yes
visualize: no

You can run 'make' or 'make fprofiled' now.

やっと、./configureが無事とおりました。

●コンパイル
./configureでは、makeもしくは make fprofiledを実行せよと書かれていますが、
FreeBSDでは、gmakeを使います。makeでは、Makefileの構文エラーが出てしまいます。
> gmake

コンパイルが始まりますが、途中でlog2fが見つからないとコンパイルエラーが発生します。
確かに/usr/include/math.h の中には、定義されていませんでした。
ネット上の情報では、7.0-CURRENT i386には、あるような記事もありましたが、8.0-RELEASE amd64には、無いようです。
英語の情報では、log2fの使用部分を書き換えて対応しているものがありました。
また、日本語でも以下のような情報もありました。

-- http://www.fenix.ne.jp/~G-HAL/whatsnew/20094th.htmlより抜粋 ---
log2, log2f, log2l は C99 POSIX.1-2001 だとかで、 GNU/Linux方面だと GNU libc 2.1系にて実装済みだが、 *BSD系では未実装らしい。C99化それ自体に関しては、 GNU/Linux でも完了していないっぽい (ISO/IEC 9899:1999/Cor.3:2007 まで含めると Missing とか Broken とか言う項目が残っている)。 FreeBSD だと 8.X系にて一部は実装済みだが、完了まではまだまだらしい。 賽の河原? C++0x 出ちゃう……。そう言えば、FreeBSD の C99 対応に関して、 C99仕様の thread-safe な関数に仕様変更しようとして、 POSIX で非thread-safe と規定されている関数まで間違って thread-safe にしてしまっていらんバグが増えた、 とか言うウワサも聞いたような……。
ports を古い版にして x264 の 2008年版にしたら、 log2f() を使っていなかったのでインストールが通った。
最新版を使いたいなら、 log2f(i+1) → (logf(i+1)/logf(2)) する。
---------------------------------------------------------------

とりあえず、"log2f(i+1)"を
"(logf(i+1)/logf(2))" または、"logf(i+1)*2.8853900817779268f"のどちらかに書き換えれば良いようです。
log2fを使用しているソースは、encoder/analyse.c に一箇所あるので、それを書き換えます。

再度コンパイルするとコンパイルが通りました。
rootになりmake installでインストールし、make cleanで後始末します。
> gmake
> su
# gmake install
> gmake clean

Ubuntuでは、結構楽にコンパイル&インストール出来たのに、
OSが異なるとこんなに違うものだとは思わなかった。


この広告は前回の更新から一定期間経過したブログに表示されています。更新すると自動で解除されます。