Problems and Solutions for FFMPEG + x264 porting to S3C2410

Source: Internet
Author: User
Tags parse error

* ******* Environment: Ubuntu 8.04 *****************
* ******* Cross-compiler: 2.95.3 *****************
* ******* FFMPEG and x264 ************************ downloaded by SVN *****************
1. Cross-compile x264
# Cc = arm-Linux-GCC./configure -- prefix =/usr/local -- Host = arm-Linux
Then make, the following problem occurs:
Common/CPU. C: In function 'x264 _ cpu_num_processors ':
Common/CPU. C: 212: 'cpu _ set_t 'undeclared (first use in this function)
Common/CPU. C: 212: (each undeclared identifier is reported only once
Common/CPU. C: 212: for each function it appears in .)
Common/CPU. C: 212: Parse error before 'P _ aff'
Common/CPU. C: 213: 'P _ aff 'undeclared (first use in this function)
Common/CPU. C: 214: Warning: Implicit declaration of function 'sched _ getaffinity'
Make: *** [common/CPU. O] Error 1
Solution:
Find the x__cpu_num_processors function in common/CPU. C. The function contains the following code to obtain the number of CPUs on your computer:
# Elif defined (sys_linux)
Unsigned int bit;
Int NP;
Cpu_set_t p_aff;
Memset (& p_aff, 0, sizeof (p_aff ));
Sched_getaffinity (0, sizeof (p_aff), & p_aff );
For (Np = 0, bit = 0; bit <sizeof (p_aff); bit ++)
NP + = (uint8_t *) & p_aff) [bit/8]> (bit % 8) & 1;
Return NP;
Change it:
# Elif defined (sys_linux)
// Unsigned int bit;
Int NP;
// Cpu_set_t p_aff;
// Memset (& p_aff, 0, sizeof (p_aff ));
// Sched_getaffinity (0, sizeof (p_aff), & p_aff );
// For (Np = 0, bit = 0; bit <sizeof (p_aff); bit ++)
// NP + = (uint8_t *) & p_aff) [bit/8]> (bit % 8) & 1;
NP = 1; // The number of CPUs on your computer
Return NP;
Then, make again to solve the problem. Next, make install. The following problems may occur:
Install-D/usr/local // bin/usr/local // include
Install-D/usr/local // lib/pkgconfig
Install-M 644 x264.h/usr/local // include
Install: cannot create regular file '/usr/local // include/x264.h': Permission denied
Make: *** [install] Error 1
Solution: Switch to root.
2. Next, cross-compile FFMPEG to add x264. First, configure:
#. /Configure -- prefix =/usr/local/-- Cross-compile -- arch = libavcodec/armv4l/-- Cross-Prefix =/usr/local/ARM/2.95.3/bin/ARM-Linux --- cc = GCC -- enable-static -- disable-ipv6 -- enable-libx264 -- enable-GPL -- enable-pthreads -- disable-ffserver -- disable-ffplay -- target-OS = Linux -- disable-network -- disable-opts
The following error occurs:
Bash:./configure:/bin/sh ^ m: Bad Interpreter: no such file or directory
The reason is that the configure is written in windows, so a Ctrl + m will be added to the end of each line, which is ^ m, sh becomes sh ^ m. Of course, there is no such command, so the script cannot be run. It should be okay to remove ^ m.
Solution: Convert windows configure to Linux. Run the dos2unix configure command to install it without the dos2unix command. Or execute
Cat./configure. Sh | tr-D'/R'> temp. Sh
MV temp. Sh Configure. Sh
And then configure. If there are still errors, such:
Error: x264 not found you can add the libx264 library to configure: -- extra-libs =/usr/local/lib/This path is your x264 installation path.
Warning: Unknown CPU "./libavcodec/armv4l/", ignored. If this error occurs, change -- CPU = libavcodec/armv4l/to -- arch = libavcodec/armv4l/
If the following error occurs,
/Usr/local/ARM/2.95.3/bin/ARM-Linux-GCC is unable to create an executable file.
C Compiler Test failed.
It will be found that this error will be removed after -- extra-libs =/usr/local/lib/is removed, but there is an error: x264 not found, which is depressing. How can this problem be solved?
......

I re-compiled and installed x264, and changed its prefix from -- prefix =/usr/local to the directory of the cross compiler, -- prefix =/usr/local/ARM/2.95.3/ARM-Linux.

Next, execute make and cross-compile FFMPEG, which will encounter many problems:

<1> internal. h: 121: Invalid token in Expression

View internal. h will find that there are some macros defined, so I guess it is caused by the low version of my cross compiler, but I can only use the 2.95.3 compiler, the question goes on ...... Depressed!

......

I just tried it with the cross compiler of version 3.4.4, and it was passed once. The previous errors were not found, but I had to re-compile Vivi and kernel, I don't know what problems will happen ......

Sure enough, Vivi cannot be compiled using the cross compiler of version 3.4.4. As for the kernel, I have not tried it.

There is a "/" in line 121st of Internal. H, which is used for line feed, because sometimes a line cannot be written. It indicates that the current row and the next row are connected together. However, the 2.95.3 compiler does not seem to support "/". I removed it just now. The above error is indeed missing, but there are many other errors caused by "/". Please try again.

9-9-1-13

 

**************************************** ***

Violent sweat! I changed all the "/", but many errors occurred after the last step of compilation, as shown below:

......

/Var/tmp/last/FFMPEG/libavformat/allformats. C: 173: Undefined reference to 'rtp _ muxer'
/Var/tmp/last/FFMPEG/libavformat/allformats. C: 173: Undefined reference to 'rtsp _ demuxer'
/Var/tmp/last/FFMPEG/libavformat/allformats. C: 173: Undefined reference to 'sdp _ demuxer'
/Var/tmp/last/FFMPEG/libavformat/allformats. C: 173: Undefined reference to 'v4l2 _ demuxer'
/Var/tmp/last/FFMPEG/libavformat/allformats. C: 173: Undefined reference to 'v4l _ demuxer'
/Var/tmp/last/FFMPEG/libavformat/allformats. C: 173: Undefined reference to 'x11 _ grab_device_demuxer'
/Var/tmp/last/FFMPEG/libavformat/allformats. C: 173: Undefined reference to 'HTTP _ Protocol'
/Var/tmp/last/FFMPEG/libavformat/allformats. C: 173: Undefined reference to 'rtp _ Protocol'
/Var/tmp/last/FFMPEG/libavformat/allformats. C: 173: Undefined reference to 'tcp _ Protocol'
/Var/tmp/last/FFMPEG/libavformat/allformats. C: 173: Undefined reference to 'udp _ Protocol'
/Var/tmp/last/FFMPEG/libavcodec. A (allcodecs. O): In function 'avcodec _ register_all ':

......

I don't know how to change it.

**************************************** **************************************** *******************

I downloaded a relatively low-case ffmpeg, which is ffmpeg-0.4.9-p20060530.tar.bz2. It also supports x264 and may also be compiled using 2.95.3. But there are still many problems.

<1> ************************************* **************************************** ************

In file encoded ded from huffyuv. C: 29:
/Var/tmp/old/ffmpeg-0.4.9-p20060530/libavutil/common. h: 620: Warning: static Declaration for 'lrintf' follows non-static
Huffyuv. C: In function 'encode _ 422_bitstream ':
Huffyuv. C: 679: Internal error -- unrecognizable insn:
(Insn 207 203 211 (SET (REG: Si 118)
(Zero_extend: Si (MEM: Qi (plus: Si (REG: Si 116)
(Subreg: Si (REG: di 84) 0)-1 (insn_list 203 (NiL ))
(Expr_list: reg_dead (REG: Si 116)
(NiL )))
Make [1]: *** [huffyuv. O] Error 1

The solution is to modify the source code, because the compiler version is too low and cannot be identified, so I changed it to another code, and the compilation passed, but I do not know whether it can be used or not. The code for the functions encode_422_bitstream and encode_gray_bitstream of huffyuv. C is as follows:

Static int encode_422_bitstream (hyuvcontext * s, int count ){
Int I, a, B, c, d;

If (S-> Pb. buf_end-S-> Pb. Buf-(put_bits_count (& S-> Pb)> 3) <2*4 * count ){
Av_log (S-> avctx, av_log_error, "encoded frame too large/N ");
Return-1;
}

Count/= 2;
If (S-> flags & codec_flag_pass1 ){
For (I = 0; I <count; I ++ ){
A = s-> temp [0] [2 * I];
B = s-> temp [1] [I];
C = s-> temp [0] [2 * I + 1];
D = s-> temp [2] [I];
S-> stats [0] [a] = s-> stats [0] [a] + 1;
S-> stats [1] [B] = s-> stats [1] [B] + 1;
S-> stats [0] [c] = s-> stats [0] [c] + 1;
S-> stats [2] [d] = s-> stats [2] [d] + 1;
}
}
If (S-> avctx-> flags2 & codec_flag2_no_output)
Return 0;
If (S-> context ){
For (I = 0; I <count; I ++ ){
A = s-> temp [0] [2 * I];
B = s-> temp [1] [I];
C = s-> temp [0] [2 * I + 1];
D = s-> temp [2] [I];
S-> stats [0] [a] = s-> stats [0] [a] + 1;
Put_bits (& S-> Pb, S-> Len [0] [a], S-> bits [0] [a]);
S-> stats [1] [B] = s-> stats [1] [B] + 1;
Put_bits (& S-> Pb, S-> Len [1] [B], S-> bits [1] [B]);
S-> stats [0] [c] = s-> stats [0] [c] + 1;
Put_bits (& S-> Pb, S-> Len [0] [c], S-> bits [0] [c]);
S-> stats [2] [d] = s-> stats [2] [d] + 1;
Put_bits (& S-> Pb, S-> Len [2] [d], S-> bits [2] [d]);
}
} Else {
For (I = 0; I <count; I ++ ){
A = s-> temp [0] [2 * I];
B = s-> temp [1] [I];
C = s-> temp [0] [2 * I + 1];
D = s-> temp [2] [I];
Put_bits (& S-> Pb, S-> Len [0] [a], S-> bits [0] [a]);
Put_bits (& S-> Pb, S-> Len [1] [B], S-> bits [1] [B]);
Put_bits (& S-> Pb, S-> Len [0] [c], S-> bits [0] [c]);
Put_bits (& S-> Pb, S-> Len [2] [d], S-> bits [2] [d]);
}
}
Return 0;
}

Static int encode_gray_bitstream (hyuvcontext * s, int count ){
Int I, A, B;

If (S-> Pb. buf_end-S-> Pb. Buf-(put_bits_count (& S-> Pb)> 3) <4 * count ){
Av_log (S-> avctx, av_log_error, "encoded frame too large/N ");
Return-1;
}

Count/= 2;
If (S-> flags & codec_flag_pass1 ){
For (I = 0; I <count; I ++ ){
A = s-> temp [0] [2 * I];
B = s-> temp [0] [2 * I + 1];
S-> stats [0] [a] ++;
S-> stats [0] [B] ++;
}
}
If (S-> avctx-> flags2 & codec_flag2_no_output)
Return 0;

If (S-> context ){
For (I = 0; I <count; I ++ ){
A = s-> temp [0] [2 * I];
B = s-> temp [0] [2 * I + 1];
S-> stats [0] [a] ++;
Put_bits (& S-> Pb, S-> Len [0] [a], S-> bits [0] [a]);
S-> stats [0] [B] ++;
Put_bits (& S-> Pb, S-> Len [0] [B], S-> bits [0] [B]);
}
} Else {
For (I = 0; I <count; I ++ ){
A = s-> temp [0] [2 * I];
B = s-> temp [0] [2 * I + 1];
Put_bits (& S-> Pb, S-> Len [0] [a], S-> bits [0] [a]);
Put_bits (& S-> Pb, S-> Len [0] [B], S-> bits [0] [B]);
}
}
Return 0;
}

<2> ************************************* **************************************** ***********************

Error message:

/Var/tmp/old/ffmpeg-0.4.9-p20060530/libavutil/common. h: 620: Warning: static Declaration for 'lrintf' follows non-static
X264.c: In function 'x264 _ init ':
X264.c: 145: structure has no member named 'I _ rf_constant'
X264.c: 151: structure has no member named 'B _ CBR'
Make [1]: *** [x264.o] Error 1
Make [1]: Leaving directory '/var/tmp/old/ffmpeg-0.4.9-p20060530/libavcodec'
Make: *** [lib] Error 2

Change Method: Modify x264.c's x__init function. You only need to modify the two rows. Rows 145 and 151 can be modified.

If (avctx-> CRF) X4-> Params. Rc. f_rf_constant = avctx-> CRF; // the modified Code
Else if (avctx-> CQP>-1) X4-> Params. Rc. I _qp_constant = avctx-> CQP;
}

// If neither CRF nor CQP modes are selected we have to enable the RC
// We do it this way because we cannot check if the bitrate has been set
If (! (Avctx-> CRF | (avctx-> CQP>-1) X4-> Params. Rc. I _rc_method = x264_rc_abr; // The changed code

<3> ************************************* **************************************** **************

Error message:

/Usr/local/ARM/2.95.3/ARM-Linux/bin/ld: Unrecognized option '-- as-needed'
/Usr/local/ARM/2.95.3/ARM-Linux/bin/ld: Use the -- help option for usage information
Collect2: LD returned 1 exit status
Make: *** [ffmpeg_g] Error 1

This problem has plagued me for a long time. I guess that -- as-needed is in a makefile, but it cannot be found. The problem is still caused by the low version of the compiler. I used a dirty method temporarily and changed the LD of 2.95.3 with the LD of 3.4.4. The compilation was successful for the moment, after obtaining the FFMPEG executable file, I just don't know if it can be used. I 'd like to try it on the lab board tomorrow morning. I hope there will be no problem, huh, huh.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.