forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PS2 network media player?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development
View previous topic :: View next topic  
Author Message
mountainstorm



Joined: 07 Apr 2004
Posts: 21

PostPosted: Mon Sep 06, 2004 12:25 am    Post subject: PS2 network media player? Reply with quote

Ive got a PS2, the Sony DVD remote and the network adapter.... and I want to use it to watch video. Now Ive tried the PS2Reality player and whilst its ok, im not overly impressed.

What i want is the equivolent of the Happauge MVP using my PS2 as little more than a network -> TV player and a remote control -> network device. The idea is to make the PC do ALL the work and generate the menus' etc in the format the PS2 can understand (translate). Now converting all my movies into a good format is easily achieved on the PC with Video Lan Client, so i need a video codec for my PS2.

I believe PS2Reality use ffmpeg, but im having limited success trying to compile that with the toolchain. Has anybody managed to get even a limited subset of ffmepg compiled and working on the PS2? Im only looking for a codec which the PS2 will not have problems with - so mabe MPEG2 might be the best choice.... anybody?

Rich
Back to top
View user's profile Send private message
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Mon Sep 06, 2004 12:57 am    Post subject: Reply with quote

PS2Reality claim that they submitted patches to ffmpeg's crew, and that it's available somewhere deeply in ffmpeg's webpage. I haven't suceeded yet finding it. If you can find it, please let me know.
_________________
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Mon Sep 06, 2004 5:34 am    Post subject: Reply with quote

All PS2Reality did was to change the MMX routines in FFMPEG into MMI routines for the EE. If you get a current snapshot of FFMPEG, you'll find the MMI code for things like IDCT. That's the ONLY change they made for video.

As far as I can tell, PS2Reality is just cobbled together from FFMPEG, libmad, libvorbis, and some PS2 routines. I'm still looking into a conversion of xine for the PS2, but I've been rather busy on other things.
Back to top
View user's profile Send private message AIM Address
mountainstorm



Joined: 07 Apr 2004
Posts: 21

PostPosted: Mon Sep 06, 2004 6:07 am    Post subject: Reply with quote

Well I searched the ffmpeg dev mailing list and apparently they are only using libavcodec rather than libavformat. Ive tried compiling libavcodec with the ee toolchain, after configuring it as a mips machine.... this causes the compile to use the mmi routines in the ps2/ directory.

The only thing which doesn't compile is mpegaudiodec.c IIRC, this causes the compiler to crash! So Ive removed that and it claims it has compiled. Im currently trying to knock up a simple program to prove to myself its working.... its got about a meg of .mpg file embedded in the source file!

Does anybody know which codec requires the least processor power to decode?

Rich
Back to top
View user's profile Send private message
mountainstorm



Joined: 07 Apr 2004
Posts: 21

PostPosted: Mon Sep 06, 2004 7:20 am    Post subject: Reply with quote

So Ive got a libavcodec.a file (a good start me thinks). Ive written my small app and tested in on my Mac. Im trying to compile it with the PS2 toolchain but am missing the following symbols.....

sscanf
perror
_ctype_
atof
atoi
strtod

and quite a few other ones that I suspect are related to ffmpeg, are these avaliable and if so where?

Rich
Back to top
View user's profile Send private message
Guest






PostPosted: Mon Sep 06, 2004 3:59 pm    Post subject: Reply with quote

J.F. wrote:
All PS2Reality did was to change the MMX routines in FFMPEG into MMI routines for the EE. If you get a current snapshot of FFMPEG, you'll find the MMI code for things like IDCT. That's the ONLY change they made for video.


I can understand using MMI and the EE core to do mpeg2 motion compensation functions, since the IPU does *not* perform that bit, but I
thought that the IPU *does* do IDCT. So PS2Reality is not taking true
advantage of the entire EE (R5900/MMI + IPU) to do mpeg2 video ?
Back to top
Guest






PostPosted: Mon Sep 06, 2004 4:00 pm    Post subject: Reply with quote

mountainstorm wrote:
So Ive got a libavcodec.a file (a good start me thinks). Ive written my small app and tested in on my Mac. Im trying to compile it with the PS2 toolchain but am missing the following symbols.....

sscanf
perror
_ctype_
atof
atoi
strtod

and quite a few other ones that I suspect are related to ffmpeg, are these avaliable and if so where?

Rich


I think you would only find them in the ps2 port of newlib, since ps2sdk
does not offer a full complement of C library routines et al.

Gorim
Back to top
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Mon Sep 06, 2004 4:46 pm    Post subject: Reply with quote

Since PS2Reality only plays videos in AVI format, I don't think they bothered with any kind of optimizations for MPEG2.

The IPU can also do colorspace conversion. I'd definitely work that into a video player on the PS2.

If you're looking for something simple to test, you might try a cinepak video. That's what Apple used to use for QT movies years back. It was also popular in games.
Back to top
View user's profile Send private message AIM Address
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Mon Sep 06, 2004 8:29 pm    Post subject: Reply with quote

Code:
ee-gcc -O3 -DHAVE_AV_CONFIG_H -I.. -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -c -o mpegaudiodec.o mpegaudiodec.c
mpegaudiodec.c: In function `dct32':
mpegaudiodec.c:1653: insn does not satisfy its constraints:
(insn 2939 448 2941 (set (reg:DI 2 v0)
        (ashiftrt:DI (reg:DI 66 accum)
            (const_int 32 [0x20]))) 216 {ashrdi3_internal4} (nil)
    (nil))
mpegaudiodec.c:1653: Internal compiler error in reload_cse_simplify_operands, at reload1.c:8338
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
make: *** [mpegaudiodec.o] Error 1


"ouch!" :P (note that removing -O3 helps...)
_________________
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Back to top
View user's profile Send private message
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Tue Sep 07, 2004 3:32 am    Post subject: Reply with quote

Never use -O3 unless you know what you're doing. It turns on automatic function inlining which may be fine for certain files in your project, but is pretty harmful (and broken) overall.
_________________
"He was warned..."
Back to top
View user's profile Send private message
mountainstorm



Joined: 07 Apr 2004
Posts: 21

PostPosted: Tue Sep 07, 2004 6:06 am    Post subject: Reply with quote

whooo, cheers - well Ive removed the -O3 from config.mak and set CONFIG_ENCODERS to 0 in config.h. Then compiled it up.... and bingo it all worked.

Now with my test program compiled as well (after playing with the library order) unfortunatly the same code works on my PC with an mpeg1 sample (embedded) - on the PS2 causes a segfault. Is there a way to get the segfault on the PC instead of the TV?

So not loosing heart I created a small MPEG4 sample (we know PS2Reality does that) embedded that, setup the width and height (MPEG4 streams dont have that encoded) and tried again. This time it didnt crash, whilst it didnt log the same text as I got on my PC.. it did appear to do 'something'

Next I need to try to get some code to display the output buffer? Anybody fancy trying that?

If you want to give it a go,
* get ffmpeg
* ./configure --cpu=mips --cross-prefix=ee- --disable-ffserver --disable--ffplay
* Mod the config.h and config.mak (see above)
* cd into libavcodec and 'make'
* copy the libavcodec.a and all the header files into your PS2 toolchain
* get my test file (its shambled together from apiexamples.c) from http://www.mountainstorm.co.uk/ps2dev.mountainstorm.co.uk/main.c
* get the make file http://www.mountainstorm.co.uk/ps2dev.mountainstorm.co.uk/Makefile
* make the example, and dump it on your PS2

Feel free to try modifying the example video, or anything and report back if you have any success.

Rich
Back to top
View user's profile Send private message
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Tue Sep 07, 2004 6:46 am    Post subject: Reply with quote

I actually have a "harder" modification. Which should be a little bit faster though, and cleaner. Here are my config.h/mak:

config.h:
Code:
#define ARCH_MIPS 1
#define TUNECPU generic
#define EMULATE_INTTYPES 1
#define EMULATE_FAST_INT 1
#define CONFIG_DECODERS 1
#define CONFIG_MPEGAUDIO_HP 1
#define CONFIG_DV1394 1
#undef  HAVE_MALLOC_H
#undef  HAVE_MEMALIGN
#define SIMPLE_IDCT 1
#define CONFIG_RISKY 1
#define restrict
#define HAVE_MMI 1


config.mak:
Code:
prefix=/usr/local
bindir=/usr/local/bin
mandir=/usr/local/man
MAKE=make
CC=ee-gcc
AR=ee-ar
RANLIB=ee-ranlib
STRIP=ee-strip
LDFLAGS=-Wl,--warn-common -rdynamic
FFSLDFLAGS=-Wl,-E
SHFLAGS=-shared
LIBPREF=lib
LIBSUF=.a
EXESUF=
TARGET_OS=Linux
TARGET_ARCH_MIPS=yes
EXTRALIBS=-lm
VERSION=0.4.9-pre1
CONFIG_DECODERS=yes
CONFIG_DV1394=yes
CONFIG_RISKY=yes
SRC_PATH=/home/pixel/sources/ffmpeg
TARGET_MMI=yes

_________________
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Back to top
View user's profile Send private message
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Tue Sep 07, 2004 10:35 am    Post subject: Reply with quote

All what I can get (for now) is:

Code:
Video decoding
Codec found
context alloc'd
fame alloced
opend codec - starting loop
..saving frame   0
.saving frame   1
.[mpeg4 @ 3429712]vop not coded
.saving frame   2
.saving frame   3
.[mpeg4 @ 3429712]header damaged
Error while decoding frame 4
(it took me a while to get fully rid of the newlib, and maybe I broke things...)

--edit--

Okaaaaay, got some result here. Now, I am not an ffmpeg wizard at all, and I do not know how to interpret the results (that is, what is the format of the frames ? what shall I do to dump/display them ? etc..)

Anyway, I am way too tired to post anything now, so, I'll go to bed, and we'll see later about that. If in the meanwhile some people have some clues to give me about the format outputted by avcodec_decode_video and what to do with it, that would spare me some time later on.
_________________
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Back to top
View user's profile Send private message
mountainstorm



Joined: 07 Apr 2004
Posts: 21

PostPosted: Tue Sep 07, 2004 4:12 pm    Post subject: Reply with quote

I think the frame buffer should be in RGB format (but it may be YUV) - the codes stolen from the apiexample.c in libavcodec. In that it writes the buffer into a ppm file. I'll try running that and see what format the buffer is in.

I got a different result when I ran the code, I got 6 framers processed but didnt get any of the [mpg4 @ 578...... lines?

How hard will it be to load the data from the host machine (over pukklink). That would make life easier, I'll use virtual dub tonight and create a 'raw' MPEG4 video file (the embedded data will have an audio stream in as well).

Ill keep you informed.

Rich
Back to top
View user's profile Send private message
mountainstorm



Joined: 07 Apr 2004
Posts: 21

PostPosted: Tue Sep 07, 2004 4:44 pm    Post subject: Reply with quote

The buffers in RGB, 8bpp
Back to top
View user's profile Send private message
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Tue Sep 07, 2004 5:20 pm    Post subject: Reply with quote

mountainstorm wrote:

How hard will it be to load the data from the host machine (over pukklink). That would make life easier, I'll use virtual dub tonight and create a 'raw' MPEG4 video file (the embedded data will have an audio stream in as well).

Assuming you haven't reset the IOP...
Code:

inFile = fioOpen("host:test.mpg", O_RDONLY);

...

fioRead(inFile, *buffer, size);

...

fioClose(inFile);

_________________
Shoot Pixels Not People!
Makeshift Development
Back to top
View user's profile Send private message Visit poster's website
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Tue Sep 07, 2004 10:15 pm    Post subject: Reply with quote

Weell.... the code goes up to frame 33, then hungs with a damaged header error.
Code:
running decode: size = 653
here: *****frame 33 size=653
bytes=7f 0 0 1
qscale=2
Decoded chunk, len = 106, size goes from 653 to 547
saving frame  32, 512x384, pixel format = 0
open name host:frm-032.pgm flag 202 data 41378
open fd = 2
size = 547
running decode: size = 547
here: *****frame 34 size=547
bytes=ff fb 90 44
[mpeg4 @ 3433040]header damaged
Error while decoding frame 33


Side note: I can't believe mpeg4's output is 8bits rgba... it more likely would be yuv or something similar. It seems the actual "Pixel Format" thingy inside the whole ffmpeg is a bit broken, so, except if it is PIX_FMT_YUV420P, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples), I can't guess for sure which pixel format this codec gives.

By the way, if I take your code, and try to run it under plain linux, it simply doesn't work :P

Ah, and about debug messages and stuff: I hacked a lot inside ffmpeg, in order to add some more debug messages where I needed them, and to free it from newlib.

--edit--

It seems it IS really PIX_FMT_YUV420P there... okay, let's work it out.
_________________
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Back to top
View user's profile Send private message
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Wed Sep 08, 2004 3:17 am    Post subject: Reply with quote

Duh... of course it can't work! :)

You first need tu demux the input file. That example would work on plain mpg files...
_________________
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Back to top
View user's profile Send private message
mountainstorm



Joined: 07 Apr 2004
Posts: 21

PostPosted: Wed Sep 08, 2004 3:38 am    Post subject: Reply with quote

Ive updated main.c http://www.mountainstorm.co.uk/ps2dev.mountainstorm.co.uk/main.c and now have a raw mp4 encoded test video stream http://www.mountainstorm.co.uk/ps2dev.mountainstorm.co.uk/test.mpg

Ive compiled this on Win2K and it produces 196 pgm files, I was wrong earlier as I was looking at the ppm spec (which is 3x8bpp) ... the pgm's generated are the video's frames and are greyscale 8bpp images.

So im resonably shure the code is now correct'ish :)

So I compile with the toolchain and dump it onto the PS2 using PS2exec. All I get is...
Code:

PS2EXEC.EXE v1.1 (2003 New Creation Interactive.)[Lion]

'' - PC:192.168.0.2 -> PS2:192.168.0.32

PS2Libk / Pukklink...
Execute...
Waiting for PS2 connection before executing
connected ok


****** Console Mode ******

hehe 0
unmounted


hehe 0

hehe 0

hehe 0



The 'hehe 0's continue forever (Ive left it whilst I had my tea), any ideas whats going on? Nothings displayed on the TV or my console (other than the hehe's)

Rich
Back to top
View user's profile Send private message
ole



Joined: 08 May 2004
Posts: 92
Location: Czech Republic

PostPosted: Wed Sep 08, 2004 4:52 am    Post subject: Reply with quote

I'm afraid that hehe means that connection with ps2link has been lost. I use ps2exec and it happened to me too.
Back to top
View user's profile Send private message
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Wed Sep 08, 2004 6:21 am    Post subject: Reply with quote

This was outputted by the PS2, using more or less our source code: (among other pictures)

http://www.nobis-crew.org/~pixel/frm-049.png

Okay, I don't wanna dig inside libavformat... but now, a demuxer is needed to demux files like avis...

*sigh*

I'll already hit the libavformat so it won't use newlib anymore, and well'see...
_________________
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Back to top
View user's profile Send private message
mountainstorm



Joined: 07 Apr 2004
Posts: 21

PostPosted: Wed Sep 08, 2004 6:29 am    Post subject: Reply with quote

Groovy, any ideas on why I'm loosing my connection to the PS2?

I was planning on just porting the rtp part of libavformat, that way I can run VLC on my PC and get that to do all the hard work.

Cheers for your help, I wouldnt mind seeing your source-code, I might work on getting color next :)

Rich

P.S is there a reason you dont like newlib? What are the alternatives?
Back to top
View user's profile Send private message
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Wed Sep 08, 2004 7:24 am    Post subject: Reply with quote

My source code is essentially removing stuff. I'll of course release it when we'll have something interesting. Until now, it's only some mere hacks put together. I think I am really gonna work on a "mediaplayer" for the PS2 now...

Newlib is bloated. I'll try to make sure to get rid of it sometime in the future. Until now, you have to swap functions like open -> fioOpen, etc, and forget about f* functions, like fopen, fprintf, fgetc, unputc, ... also forget about stderr.

The "alternative" is the built-in 'libc' which is inside ps2sdk. But it lacks lots of "compatibility" functions, which, in the general case, are more or less aliases with a few more checks. Maybe I'll add that later on. I am a bit fed up to "port" pieces of code to ps2sdk, where it could natively work :p
_________________
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Wed Sep 08, 2004 9:03 am    Post subject: Reply with quote

Unless the codec does colorspace conversion itself, mpeg4 codecs deal only with YUV420 format data. The xvid vfw codec has a variety of colorspace conversion routines that convert the yuv data into whatever mode the ouput bitmap is in when decoding, or vice-versa when encoding. If I remember correctly, the xvidcore only deals with yuv data.
Back to top
View user's profile Send private message AIM Address
mountainstorm



Joined: 07 Apr 2004
Posts: 21

PostPosted: Thu Sep 09, 2004 3:34 am    Post subject: Reply with quote

Your right, the frame we get is in PIX_FMT_YUV420P, and needs conversion.. using some code from http://www.inb.uni-luebeck.de/~boehme/libavcodec_update.html Ive nearly got it working, I'll keep you all updated when I do.... I think the codes getting a little messy :)

Ive also move to ps2client and now it actually works, Im even getting it to output its results, but with newlib i.e. fwrite I get zero length files and with fioWrite i get 2Mb files of junk?

Rich
Back to top
View user's profile Send private message
mountainstorm



Joined: 07 Apr 2004
Posts: 21

PostPosted: Thu Sep 09, 2004 5:56 am    Post subject: Reply with quote

Ive updated the main.c (see an earlier post for the link) it now reads the input stream from the file specified at argv[1], and outputs the frames to the file specified at argv[2] (with a number and .ppm appended).

It reads the stream, decodes it as MPEG4 converts the YUV frame to RGB and then writes it out as a ppm (color pixmap).

Ive tested it under MSVC and it works, it compiles fine under the PS2 toolchain and when run im having the same 'zero length output file' problem i had before. It has alos thrown an error when decoding one of the frames. The decode error might be a problem with my code (its actually a mod'd version of the link i posted in my last post). But does anybody have any ideas about my zero length file issue.

Mabe I need a new version of PS2Link?

Rich
Back to top
View user's profile Send private message
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Thu Sep 09, 2004 9:47 pm    Post subject: Reply with quote

I think you shouldn't use the newlib at all. Well, let me hack your code now, I'll make it working, don't worry :p

--edit--

Okay, well, this code still doesn't make any use of the libavformat. So, yeah, this code works great with mpeg files (I decoded your test.mpg yet again), but it won't demux any .avi file.
_________________
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Back to top
View user's profile Send private message
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Fri Sep 10, 2004 9:25 pm    Post subject: Reply with quote

So... finally, ps2sdk now come with a small "stdio" support, which should help you get rid of newlib. It doesn't have any sscanf/strtod/atof though. But these are used only in some configuration thingies, so, you can kill the code off. On a side note, if somebody have some simple implementation of sscanf/strtod/atof, that would be some great addictions to the actual ps2sdk's libc.

Now, just changing ffmpeg's makefiles should be enough (that is, put some CFLAGS so they have -I$(PS2SDK)/ee/include and -I$(PS2SDK)/common/include )

So, now, you shouldn't need "newlib's libc" anymore, and should give more stable results. I'll let you do your tests, I have other things to take care of right now, but I'll come back help you a little bit afterward.
_________________
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group