Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.

MPEG2 encoder segfault

Shaun_Marko
Beginner
1,539 Views
Hello,

I'm new to IPP, so I'm probably missing something rather simple. Attached is test code that crashes when instantiating a structure which contains an MPEG2VideoEncoder object and an MPEG2EncoderParam object. The debugger indicates the crash occurs in the MPEG2EncoderParams constructor when it assigns default values to the IntraQMatrix data member:

lnet@I5-desktop$ idbc ./mp2
Intel Debugger for applications running on IA-32, Version 12.0, Build [1.3842.2.129]
------------------
object file name: ./mp2
Reading symbols from /home/lnet/work/mp2/mp2...done.
(idb) run
Starting program: /home/lnet/work/mp2/mp2
[New Thread 3077773568 (LWP 24206)]
[New Thread 3077773568 (LWP 24206)]
Program received signal SIGSEGV
UMC::MPEG2EncoderParams::MPEG2EncoderParams (this=0x87e50a8) at /home/lnet/work/ipp-samples/audio-video-codecs/codec/mpeg2_enc/src/umc_mpeg2_enc_params.cpp:117
117 IntraQMatrix = DefaultIntraQuantMatrix;
(idb) where
#0 0x0804cbdb in UMC::MPEG2EncoderParams::MPEG2EncoderParams (this=0x87e50a8) at /home/lnet/work/ipp-samples/audio-video-codecs/codec/mpeg2_enc/src/umc_mpeg2_enc_params.cpp:117
#1 0x0804f729 in UMC::MPEG2VideoEncoderBase::MPEG2VideoEncoderBase (this=0x0) at /home/lnet/work/ipp-samples/audio-video-codecs/codec/mpeg2_enc/src/umc_mpeg2_enc.cpp:24
#2 0x0804ec46 in UMC::MPEG2VideoEncoder::MPEG2VideoEncoder (this=0x340) at /home/lnet/work/ipp-samples/audio-video-codecs/codec/mpeg2_enc/src/umc_mpeg2_video_encoder.cpp:35
#3 0x0804c801 in Foo::Foo (this=0x87e4d10) in /home/lnet/work/mp2/mp2
#4 0x0804c798 in main (argc=1, argv=0xbfac5304) at /home/lnet/work/mp2/mp2.cpp:15
#5 0x005a6ce7 in __libc_start_main () in /lib/libc-2.12.1.so
#6 0x0804c6a1 in _start () in /home/lnet/work/mp2/mp2
(idb)

I may be barking up the wrong tree, but it appears the IntraQMatrix should be 16-byte aligned and it is not:
(idb) print &IntraQMatrix
$2 = (Ipp16s (*)[64]) 0x87e5178
(idb) print &IntraQMatrix%16
$3 = 8

If the Foo structure containing the MPEG2VideoEncoder and MPEG2EncoderParams objects is created on the stack rather than allocated from the heap, the crash does not occur.

I'm running the code on a core I5 machine with 32-bit Ubuntu 10.10 OS:
uname: Linux I5-desktop 2.6.35-22-generic #33-Ubuntu SMP Sun Sep 19 20:34:50 UTC 2010 i686 GNU/Linux
Compiler: Intel C++ Compiler XE for applications running on IA-32, Version 12.0.0.084 Build 20101006
ipp samples: linux 7.0.1.029

Any pointers would be greatly appreciated.

-Shaun





0 Kudos
9 Replies
Vladimir_Dudnik
Employee
1,539 Views
Hi Shaun,

please check with audio-video-codecs sample how to use UMC object and structures. We do not see crashes in compiled UMC sample code.

Regards,
Vladimir
0 Kudos
Shaun_Marko
Beginner
1,539 Views
Hi Vladmir,

Thanks for the reply. Unfortunately, I'm seeing a crash with the sample code:

lnet@I5-desktop$ idbc ./umc_video_enc_con
Intel Debugger for applications running on IA-32, Version 12.0, Build [1.3842.2.129]
------------------
object file name: ./umc_video_enc_con
Reading symbols from /home/lnet/test/umc_video_enc_con...done.
(idb) run -y img -o video.mpg mpeg2.par
Starting program: /home/lnet/test/umc_video_enc_con
[New Thread 3079510272 (LWP 7779)]
[New Thread 3079510272 (LWP 7779)]
Program received signal SIGSEGV
UMC::MPEG2EncoderParams::MPEG2EncoderParams (this=0x9e11628) at /home/lnet/work/ipp-samples/audio-video-codecs/codec/mpeg2_enc/src/umc_mpeg2_enc_params.cpp:117
117 IntraQMatrix = DefaultIntraQuantMatrix;

My application worked with the 11.1 version of the C++ professional compiler for linux that I used to evaulate the product. The license my company purchased was for the composerxe-2011 version. After installing that and rebuilding with the licensed compiler, may application segfaults.

-Shaun

0 Kudos
Chao_Y_Intel
Moderator
1,539 Views

Shaun,

Can you provide the par file, and related input YUV file?

thanks,
Chao

0 Kudos
Shaun_Marko
Beginner
1,539 Views
The sample application segfaults when using just the mpeg2.par included with the samples, like this:
./umc_video_enc_con m2 ../../application/umc_video_enc_con/mpeg2.par video.mpg
Segmentation fault

A program as simple as this segfaults in the same location in the MPEG2EncoderParams constructor:

#include
#include
#include
#include
#include
#include
#include

using namespace UMC;


int main(int argc, char **argv)
{
MPEG2VideoEncoder *encoder = new MPEG2VideoEncoder;
MPEG2EncoderParams *params = new MPEG2EncoderParams;

std::cout << params->gopSize << std::endl;

return 0;
}



-Shaun

0 Kudos
Chao_Y_Intel
Moderator
1,539 Views


Shaun,

The code in the line looks fine: codecs/codec/mpeg2_enc/src/umc_mpeg2_enc_params.cpp:117

117 IntraQMatrix = DefaultIntraQuantMatrix;

If you use GCC to build the sample, how does it work for you?

Thanks,
Chao

0 Kudos
Shaun_Marko
Beginner
1,539 Views
Hi Chao,

The GCC build of umc_video_enc_con appears to work fine:

$ ./umc_video_enc_con -n 100 -i /dev/urandom ../../application/umc_video_enc_con/mpeg2.par video.mpg
Starting MPEG2 encoding /dev/urandom to file video.mpg
Source video width = 352, height = 288, frameRate = 24.00
Max frames to encode = 100
Encoding bit rate = 5300000 bits per second
0.10.20.30.40.50.60.70.80.90.100.
Summary:
Num frames encoded = 100
Encoding Time = 0.15 sec, 669.73 fps
Overall Time = 1.97 sec, 50.82 fps
Average CPU usage = 0.00%
Encoded Size = 2759608 bytes
Compression Ratio = 5.51
EncodedSize/ExpectedSize = 1.00

Incidentally, this test was run on a fresh install of Intel ComposerXE 2011 for linux and the latest IPP samples on Ubuntu 10.4 (32-bit). The ICC build of the umc_video_enc_con sample application still segfaults:

$ ./umc_video_enc_con -n 100 -i /dev/urandom ../../application/umc_video_enc_con/mpeg2.par video.mpg
Segmentation fault

Thanks for your help.

-Shaun


0 Kudos
Shaun_Marko
Beginner
1,539 Views
Chao,

Have you been able to reproduce this issue? I provided a simple test case that fails on my Linux Ubuntu 10.4 system.

-Shaun
0 Kudos
Chao_Y_Intel
Moderator
1,539 Views


Shaun,

I have a test here. I can see the error you report here. The problem seems that the compiler is generating the incorrect code on the following line ( This line of the code looks fine in the source)

117 IntraQMatrix = DefaultIntraQuantMatrix;

Since GCC compiler can work well, I also tried to compile the source with O0 option ( in the Makefile change CFLAGS = -Wall -O0 fPIC), the sample code also works fine. So possibly you can use -O0 as workaround for build MPEG2 encoder.

Thanks,
Chao

0 Kudos
Shaun_Marko
Beginner
1,539 Views
Chao,

Thanks for the follow up. I'll run with the GCC compiler or the -O0 optimizations on the Intel compiler until this problem is resolved. Thanks again.

-Shaun
0 Kudos
Reply