Ffmpeg (Compile Problems)

From ConShell
Jump to navigation Jump to search

An anonymous user (172.192.93.173 an AOL IP) provided some solutions to compiling problems I was having. I moved them to this page. I will organize this page better as I attempt the solutions he provides. I would like to note here that I am using ffmpeg on linux, and this user apparently compiles ffmpeg from gcc with cygwin in windows. The fact that we both encounter the same errors would suggest the same solutions would work. --198.143.78.193 00:17, 11 November 2006 (EST)

Errors that occur

h264 (Quicktime 7 Codex

--enable-x264

Causes the following compile error to occur:
gcc -DHAVE_AV_CONFIG_H -I.. -I/usr/local/src/ffmpeg/libavutil -pthread -g -Wdeclaration-after-statement -Wall -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Winline -O3 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_ISOC9X_SOURCE    -c -o x264.o x264.c
x264.c: In function `X264_init':
x264.c:146: error: structure has no member named `i_rc_method'
x264.c:146: error: `X264_RC_CRF' undeclared (first use in this function)
x264.c:146: error: (Each undeclared identifier is reported only once
x264.c:146: error: for each function it appears in.)
x264.c:149: error: structure has no member named `i_rc_method'
x264.c:149: error: `X264_RC_CQP' undeclared (first use in this function)
x264.c:156: error: structure has no member named `i_rc_method'
x264.c:156: error: `X264_RC_ABR' undeclared (first use in this function)
x264.c:228: error: structure has no member named `b_fast_pskip'
x264.c:231: error: structure has no member named `i_noise_reduction'
make[1]: *** [x264.o] Error 1

Compile Optimizations

--disable-opts

Fails with this error
gcc -DHAVE_AV_CONFIG_H -I.. -I/usr/local/src/ffmpeg/libavutil -pthread -g -Wdeclaration-after-statement -Wall -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Winline -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_ISOC9X_SOURCE    -c -o i386/dsputil_mmx.o i386/dsputil_mmx.c
i386/dsputil_mmx.c: In function `transpose4x4':
i386/dsputil_mmx.c:632: error: can't find a register in class `GENERAL_REGS' while reloading `asm'
i386/dsputil_mmx.c: In function `gmc_mmx':
i386/dsputil_mmx.c:2482: warning: suggest parentheses around arithmetic in operand of |
i386/dsputil_mmx.c:2482: warning: suggest parentheses around arithmetic in operand of |
i386/dsputil_mmx.c:2483: warning: suggest parentheses around arithmetic in operand of |
i386/dsputil_mmx.c:2483: warning: suggest parentheses around arithmetic in operand of |
i386/dsputil_mmx.c:2483: warning: suggest parentheses around arithmetic in operand of |
make[1]: *** [i386/dsputil_mmx.o] Error 1
make[1]: Leaving directory `/usr/local/src/ffmpeg/libavcodec'

Solutions

Note about optimizing and GENERAL_REGS errors in ffmpeg

When compiling ffmpeg you might want to use these flags on these (and other) files (short example, I use MANY flags):

gcc -O3 -Wdisabled-optimization -Wall -o C:/ffmpeg-SVN/libavcodec/i386/mpegvideo.o C:/ffmpeg-SVN/libavcodec/mpegvideo.c

gcc -O3 -Wdisabled-optimization -Wall -o C:/ffmpeg-SVN/libavcodec/i386/dsputil_mmx.o C:/ffmpeg-SVN/libavcodec/i386/dsputil_mmx.c

The above lines (depending on your gcc version) may produce warnings that say "--param large-function-growth limit reached"

These can be reduced (but you _most_ _likely_ would NOT want to eliminate them completely) by adding this to the command line: -funit-at-a-time --param large-function-growth=800 --param max-inline-insns-single=3000

The defaults for these values are in "gcc.info" (some people can type "info gcc" to view this file).

Upon using the previously mentioned flags (AND many of your favourites in addition) you may get an error that says: "i386/dsputil_mmx.c:636: error: can't find a register in class `GENERAL_REGS' while reloading `asm'".

You may be using a flag that 'promotes' such an error to occur. Use Google (or other search engine) to find the above error line - many people are complaining about it. The "so-called" answer is that it is a compiler bug. That may well be, but it can be 'fixed' (on the command line).

In your "C:\ffmpeg-SVN\libavcodec\Makefile" (I imaging that is were you put it) add a few lines such as these right after "apiexample: apiexample.o $(LIB)" :

# Special for i386/dsputil_mmx.c - don't use "-fstack-check"
i386/dsputil_mmx.o: i386/dsputil_mmx.c
	$(CC) $(CFLAGS) -fno-stack-check -c -o $@ $<

This will compile all the other files with the flags that you set as a default by configuring thusly:

./configure --enable-xyz-whatever-encoders-decoders-etc --extra-cflags="-march=athlon-xp -msse -mfpmath=sse -O3 -f-many-more -fstack-check

but it will 'delete' "-fstack-check" which causes the "GENERAL_REGS" on THAT particular file with SOME versions of gcc. You may need to tweak different flags to avert the compiler error. You can use (as a last resort) -march=i386 -O0 to avoid stressing gcc - best to play with the flags first.

Another good choice is to try to change the whole line for just ONE file and use ALL your default flags for the rest of the files:

Add a line to the Makefile above dirrectly after the last one for this next troublesome file ...

# Works - omit "-fstack-check" -- Use "--param large-function-growth=160 --param max-inline-insns-single=3000" 
# instead of using from: --param large-function-growth=200 _TO_ --param large-function-growth=800
# Trying -fno-unit-at-a-time won't disable "--param large-function-growth=x" _OR_ "--param max-inline-insns-single=x"
#  even though the DOCs (gcg.info) claim -funit-at-a-time is needed so they are not ignored
Spec_1_CFLAGS = -I/cygdrive/C/ffmpeg-SVN/libswscale -DIF2=1  -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_ISOC9X_SOURCE -I/cygdrive/C/ffmpeg-SVN -I/cygdrive/C/ffmpeg-SVN/libavutil \
-I/usr/local/include -O3 -march=athlon-xp -msse -mfpmath=sse -g -Wall -malign-double -pipe \
-fomit-frame-pointer -momit-leaf-frame-pointer -fgcse-lm -fgcse-sm -fforce-addr -frename-registers \
-funroll-loops -Wdisabled-optimization -fprefetch-loop-arrays -frerun-cse-after-loop -frerun-loop-opt \
-falign-functions=4 -maccumulate-outgoing-args -funit-at-a-time --param large-function-growth=160 \
--param max-inline-insns-single=3000 -fomit-frame-pointer -march=athlon-xp \
-Wdeclaration-after-statement -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls \
-Winline

# Special for h264.c - don't use "-fstack-check"
h264.o: h264.c
	$(CC) $(Spec_1_CFLAGS) -c -o $@ $<

The (big?) change there (from _MY_ compiler line for ffmpeg) is that the default for --param large-function-growth is "claimed" in the DOCs (gcc.info) (haven't seen the source) to be 200. When I change it to 160 I can compile that file without getting the "can't find a register in class `GENERAL_REGS' while reloading `asm'" error. Finding defines for "X264_RC_CRF", "X264_RC_CQP", and "X264_RC_ABR" is a different problem. As the previous writer stated --enable-x264 is broken (as of Nov 8 2006) and has been for months. The author of that section of code 'must' be compiling it somehow so a search of the net for a few defines is in order...

Using this method you can attempt to optimize ffmpeg and attempt to eliminate the "GENERAL_REGS" error until your compiler is fixed. Note: I AM using the newest version of cygwin, with all current updates. I am also using the newest source for ffmpeg and all it's many included .libs. I am NOT compiling with the "-no-cygwin" flag during this attempt to compile ffmpeg - thus a few things get left out (vhooks SDL imlib2).


Found it!

Click to see it all: https://trac.videolan.org/x264/browser/trunk/x264.h?rev=537 Click to get next link: https://trac.videolan.org/x264/changeset/537/trunk/x264.h Click to get x264.h in .zip format: https://trac.videolan.org/x264/changeset/537/trunk/x264.h?format=zip&new=537

I know it is NOT from ffmpeg OR libx264 but it does have the few missing defines needed to compile and this is a trustworthy source to obtain the file and the info VLC uses working x/h264.