Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

libmpeg2dec-0.5.1 problems

Altera_Forum
Honored Contributor II
1,680 Views

Hi everyone, 

 

My problem is still the same as in this thread 

http://www.alteraforum.com/forum/showthread.php?t=16937 

but all the links from there are dead meanwhile, so i'll respawn this here: 

 

I build mpeg2dec (from of libmpeg2dec-0.5.1, http://libmpeg2.sourceforge.net/) for nios like this: 

CC=nios2-linux-uclibc-gcc LDFLAGS=" -elf2flt" ./configure --host=nios2-linux-uclibc --disable-shared --enable-static --without-x --disable-sdl --prefix=/opt/nios2 && makeI build mpeg2dec on my linux-pc like this: 

./configure --disable-shared --enable-static --without-x --disable-sdl && makeconfiguring and compiling seems to work OK in both cases. 

 

As Input bitstream i use always this one (gunzipped): 

http://standards.iso.org/ittf/publiclyavailablestandards/iso_iec_13818-4_2004_conformance_testing/video/bitstreams/main-profile/nokia/nokia_7/nokia7_dual.bit.gz 

So, my command-line calling mpeg2dec looks like:  

mpeg2dec -o pgm mnt/nokia7_dual.bitIn both cases (pc and nios) i get (all) four pictures from the mpeg-bitstream decoded. But on the PC Version, the pictures look like expected, while on the NIOS version the pictures look completely destroyed. (see attachments, i used convert from ImageMagick to convert from pgm to jpg) 

Could anybody be so kind and try this on his/her nios system to see, if mpeg2dec is running with proper output? 

 

cheers, 

WK
0 Kudos
7 Replies
Altera_Forum
Honored Contributor II
727 Views

Hi, 

 

I compiled the 'mpeg2dec' for my PC, but it can't decode the beautiful sand art 'Welcome.mpg' of SLS's demo. Of course, I don't know why. 

 

www.sls (http://www.%3cb%3esls%3c/b%3e)corp.com/LG/bsp/ug_uclinux_neek_bsp_1.5.pdf 

 

Kazu
0 Kudos
Altera_Forum
Honored Contributor II
727 Views

Hi, 

 

Can you provide a link to the mpeg bitstream? Maybe it's a strange format, which is not recognized by mpeg2dec. 

 

Are you able to build the mpeg2dec also for a nios system? 

 

Cheers, 

WK
0 Kudos
Altera_Forum
Honored Contributor II
727 Views

Hi, 

 

 

--- Quote Start ---  

 

Can you provide a link to the mpeg bitstream? Maybe it's a strange format, which is not recognized by mpeg2dec. 

 

--- Quote End ---  

 

 

Please refer the site 

 

http://www.slscorp.com/pages/neekbsp.php 

 

 

--- Quote Start ---  

 

Are you able to build the mpeg2dec also for a nios system? 

 

--- Quote End ---  

 

 

Not yet. Would you tell me the method of compilation? Can we do it only by selecting in the 'menuconfig'? 

 

Kazu
0 Kudos
Altera_Forum
Honored Contributor II
727 Views

Hi, 

 

 

--- Quote Start ---  

Please refer the site 

 

http://www.slscorp.com/pages/neekbsp.php 

 

--- Quote End ---  

 

 

Hmm, looks like they want some login & password, which i don't have to download anything from there... :( Any other link avaliable? 

 

 

--- Quote Start ---  

Not yet. Would you tell me the method of compilation? Can we do it only by selecting in the 'menuconfig'? 

--- Quote End ---  

 

I have no idea, wheater it's now in a uCLinux environment. I'm using a pretty old uCLinux, where it was not included (but it looks like my uClinux uses the same gcc: V3.4.6). 

So i took the tarball directly from the sourceforge link (see my 1st Post, followed "Download" link and took the newest Version 0.5.1) , untarred it (tar -xzvf libmpeg2-0.5.1.tar.gz) and used the mentioned commandline to configure and build it. It doesn't change anything outside its directory if you dont do a "make install". After configuring and building, i just copied the mpeg2dec binary from libmpeg2-0.5.1/src/ to a directory, wich i'm able to access from my nios system via nfs. 

It's a self designed custum board, doing some MPEG-TS processing on a EP2C35, and it would be a really nice feature, to be able to decode some pictures. Of course it's far from realtime, but a single picture every 10-20 sec or so would be totally sufficient. 

I've already tried older versions of mpeg2dec and different (also no) optimizations for gcc - result looks always the same. 

Meanwhile i also build it with a crosscompiler for a coldfire processor, which like nios doesnt have any MMX or SSE extentions - the resulting binary worked fine! I'm getting really confused now... 

 

Cheers 

WK
0 Kudos
Altera_Forum
Honored Contributor II
727 Views

Hi, 

 

 

--- Quote Start ---  

 

Hmm, looks like they want some login & password, which i don't have to download anything from there... :( Any other link avaliable? 

 

--- Quote End ---  

 

 

Maybe, you can easily resister your e-mail account and get the password from here. 

 

http://www.slscorp.com/pages/login.php?login=login_again 

 

 

--- Quote Start ---  

 

I have no idea, wheater it's now in a uCLinux environment. I'm using a pretty old uCLinux, where it was not included (but it looks like my uClinux uses the same gcc: V3.4.6). 

 

--- Quote End ---  

 

 

It seems that we can select 'libmpeg2' from the menuconfig, so let me see it. 

 

Kazu
0 Kudos
Altera_Forum
Honored Contributor II
727 Views

Hi, 

 

About 'Welcome.mpg', I'm sorry that it includes audio data. So with the switch '-t' 

./mpeg2dec -t Welcome.mpg we can see the beautiful sand art. 

For Nios CPU, we already have the directory '/uClinux-dist/lib/mpeg2dec', and we can select it from the 'menuconfig'. So. 

make menuconfig Kernel/Library/Defaults Selection ---> <Select> Customize Application/Library Settings < Exit > < Exit > Library Configuration ---> <Select> Build libmpeg2 < Exit > < Exit >

 

Before to 'make', please modify the file '/uClinux-dist/lib/mpeg2dec/mpeg2dec-0.4.1/configure' line 23984 like 

echo "$as_me:$LINENO: checking if libtool supports -prefer-non-pic flag" >&5 echo $ECHO_N "checking if libtool supports -prefer-non-pic flag... $ECHO_C" >&6 mkdir ac_test_libtool; cd ac_test_libtool; ac_cv_libtool_non_pic=no echo "int g (int i); static int h (int i) {return g (i);} int f (int i) {return h (i);}" >f.c echo "int (* hook) (int) = 0; int g (int i) {if (hook) i = hook (i); return i + 1;}" >g.c ../libtool --mode=compile $CC $CFLAGS -prefer-non-pic -c f.c >/dev/null 2>&1 && ../libtool --mode=compile $CC $CFLAGS -prefer-non-pic -c g.c >/dev/null 2>&1 && ../libtool --mode=link $CC $CFLAGS -prefer-non-pic -o libfoo.la -rpath / f.lo g.lo >/dev/null 2>&1 && ac_cv_libtool_non_pic=yes cd ..; rm -fr ac_test_libtool; echo "$as_me:$LINENO: result: $ac_cv_libtool_non_pic" >&5 echo "${ECHO_T}$ac_cv_libtool_non_pic" >&6 if test x"$ac_cv_libtool_non_pic" = x"yes"; then # LIBMPEG2_CFLAGS="$LIBMPEG2_CFLAGS -prefer-non-pic" <-- line 23984 LIBMPEG2_CFLAGS="$LIBMPEG2_CFLAGS -fPIC" else : fi

(Without this,we have some relocation bugs that is caused the dynamic linking.) 

After the compilation, you can get 'libmpeg2.so.0' and 'libmpeg2convert.so.0' in '/usr/lib' automatically, but copy 'mpeg2dec' in the directory 'uClinux-dist/lib/mpeg2dec/build/src/.libs' by yourself to the adequate directory e.g. '/usr/bin' with 'nokia7_dual.bit'. And please execute 

./mpeg2dec -o pgm nokia7_dual.bit In my NEEK, the result is fine. 

 

Kazu
0 Kudos
Altera_Forum
Honored Contributor II
727 Views

Moin, 

 

Sorry for the delay, meanwhile i had to do other things. 

 

 

--- Quote Start ---  

So with the switch '-t' 

./mpeg2dec -t Welcome.mpg we can see the beautiful sand art. 

--- Quote End ---  

 

That's good news! 

 

 

--- Quote Start ---  

(Without this,we have some relocation bugs that is caused the dynamic linking.) 

--- Quote End ---  

 

I think, this is the real problem with "my" mpeg2dec. When i do the change with -fPIC in the configure script, "my" mpeg2dec results look a lot better, but still not error-free. Anyway, now i know, where the problems are. Many thanks for that. 

What now works ok for me, is a real old mpeg2decoder, which can be downloaded from 

http://mpeg2videotools.sourceforge.net/ 

It compiles and runs on my nios system with almost no tweaks; here's a diff of the Makefile, which just changes the gcc and sets the -elf2flt flag during the link: 

--- mpeg2dec/Makefile 2009-12-21 12:26:24.000000000 +0100 +++ orig/mpeg2dec/Makefile 2003-02-02 17:40:32.000000000 +0100 @@ -43,9 +43,8 @@ # uncomment the following two lines if you want to include X11 support -#USE_DISP = -DDISPLAY -#LIBS = -L/usr/X11R6/lib -lX11 -LIBS = -elf2flt +USE_DISP = -DDISPLAY +LIBS = -L/usr/X11R6/lib -lX11 # uncomment the following two lines if you want to use shared memory # (faster display if server and client run on the same machine) @@ -63,7 +62,7 @@ # # GNU gcc # -CC = nios2-linux-uclibc-gcc +CC = gcc CFLAGS = -g -O2 $(USE_DISP) $(USE_SHMEM) $(INCLUDEDIR) $(TRACE) $(VERBOSE) $(VE RIFY) $(WARNINGS) OBJ = mpeg2dec.o getpic.o motion.o getvlc.o gethdr.o getblk.o getbits.o store.o recon.o spatscal.o idct.o idctref.o display.o systems.o subspic.o verify.oAnother advantage of the mpeg2decode is, that it can output colored .ppm files, so i don't have to fiddle around with the y and the 2 chroma planes seperatly. 

 

Cheers, 

WK
0 Kudos
Reply