SSブログ

各種コーディックのインストール - 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が異なるとこんなに違うものだとは思わなかった。


nice!(0)  コメント(6)  トラックバック(1) 

nice! 0

コメント 6

Bernd

私はあなたがこのサイトを書いている努力に感謝したいと思います。
私は、将来あなたと同じ高級コンテンツを見たいと思っています。
実際には、あなたの創造的なライティング能力は、今私自身の個人的なウェブサイトを手に入れるよう促しました
;)
by Bernd (2018-01-17 14:07) 

Tia

私は毎日いくつかのウェブサイトやブログを訪問して記事を読むが、このウェブサイトは質の高い投稿を提供することを除いている。
by Tia (2018-03-01 21:40) 

Francesca

こんにちは、メディアプリントに関する素晴らしい記事です
メディアを意識することは事実の大きな原因です。
by Francesca (2018-03-03 11:43) 

ליווי בישראל

היא ישבה על שפת הבריכה ועינגה את עצמה עד שהוא הגיע וזיין אותה חזק
<a href="http://scatboard.com/showthread.php?p=77052">שירותי ליווי במרכז</a>
by ליווי בישראל (2020-11-21 21:33) 

Williamineks

notaries and legal documents Authentication most of the time is in tough and mid blowing, and is why it’s neccessary to employ an expert and talented savant who will take well thought out process. Through this offering of service, one can count on us to arrange a meeting with you at a convenient spot of your liking, obtain all important documents which is the document(s) that need an notary or Authentication. I will notarize and touch up all the important documentation on your behalf. Additional verification may be needed for Authentication by The Secretary of State. We provide the letters for authentication to ensure Authentication with The Gold Sealing of GA. An Apostille requires Authentication with the secretary cooperating Authority that gices a Naotary that is accepted by towns and countires who are legions of the Hague Convention. when you happen to get a minuete have a look of my Atalnta mobile notary and apostille website: [url=https://www.atlantamobilenotaryapostille.com/][color=#000_url]apostille birth certificate near Lawrenceville Georgia[/color][/url]
by Williamineks (2022-07-05 03:48) 

HenryAmOds

My families learning group was launched by my husband. a friend of my sisters was the person who recieved the moment when of transcribing the convincing utterance of St Andrew one mid May noon in 2008… “How to speak English!”

Fifteen weeks afterwards a Jewish anmeican accent student asserted himslef and asked, “Can you show the Irish Dyslexia tools and heklpers to write American English Goood? can you come by and teach online my English teachers to teach English lessons for beginners pdf?” Check it out [url=https://teacheasyenglish.org/contact/][color=#000_url]Accent reduction class[/color][/url]
by HenryAmOds (2022-08-06 14:30) 

コメントを書く

お名前:
URL:
コメント:
画像認証:
下の画像に表示されている文字を入力してください。

トラックバック 1

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