mplayer video output (vo)

"A collection of spu programs to accelerate media related applications for the CellBE ( PS3 ) platform" - unsolo

Moderator: unsolo

Post Reply
wgarrett
Posts: 4
Joined: Mon Sep 17, 2007 11:20 am
Location: Columbia, SC USA

mplayer video output (vo)

Post by wgarrett »

I've got a rough (but working) mplayer vo built for PS3 using spu-medialib. It's very experimental and needs a lot of work. It has some issues that need to be worked out, but it seems to work (spoken cautiously) for a good variety of sources. It can't play Matroska file (.mkv), but I'm not sure that's due to the vo. I can't get them to keep proper time even with -vo null on the PS3.

I had to make some changes to spu-medialib to make it all work:

Changes I needed:
modified include files to handle c or c++
modified print statements to identify program (yuvs or yuvc) for debugging
Added creation of libspuml.a to Makefile. Contains yuvscaler.o & yuv2rgb.o for linking with mplayer (or whatever)
added install (and uninstall) to copy spu_yuv2rgb, spu_yuvscaler, libspuml.a, and include files to standard location (e.g. /usr/local/bin, /usr/local/lib64, /usr/local/include) – needs to be cleaned up & standard location/naming needs to be determined.

To do:
unsolo: Consider modifying the while loop in spu_yuv2rgb.c & spu_yuvscaler.c so that sending msg=UPDATE won't flip the buffers and cause an implied RUN (maybe move the flip statements to within the if(msg==RUN) block and then change the while loop to wait for next msg after update. No big deal either way, 'cause I'm not currently using it (msg=UPDATE)
Create proper shared library (as requested) with a more reasonable proper name
Add a debug variable to enable/squash print statements (clean up mplayer output)


Notes regarding vo_fbdev_spu

Info:
Needs to be direct rendered (use -dr)
Needs to be double buffered (use -double)
Must run fullscreen (not working with X yet)
Some video codecs WON'T double buffer (matroska formats?)
Some video broken if you don't double buffer (IPB thing – read code)
Most video scales fine, but some is just plain weird – my fault I'm sure, but haven't found it yet.

To do:
Needs a better name => fbdev_spu :(
Update configure to recognize spu-medialib automatically. After standard locations are decided for spu-medialib install, then script can check for it
Modify screen resolutions. Right now, you have to use ps3videomode first to set appropriate resolution.
Scaling is off for some video
Need to understand scaler better & re-write vo to be more friendly to it – crashes easily with unusual src sizes
Currently waiting on yuvscaler to finish before starting yuv2rgb. Need to change this, but timing & audio sync is a concern.
Implement windows to run in X!!!!!!!!
Add vo help text
Fix the many todo: messages in the code!!!!!

vo installation:

make spu-medialib library & spu* files and install:
[email protected] ~/spu-medialib/spu-medialib $ make lib

g++ -m64 -I../libfb -Iyuv2rgb -Iyuvscaler -Ispu_utils -I../../libfb/asm -O2 -c yuvscaler/yuvscaler.c -o yuvscaler.o

g++ -m64 -I../libfb -Iyuv2rgb -Iyuvscaler -Ispu_utils -I../../libfb/asm -O2 -c yuv2rgb/yuv2rgb.c -o yuv2rgb.o

ar rcs libspuml.a yuvscaler.o yuv2rgb.o


[email protected] ~/spu-medialib/spu-medialib $ make spu

spu-elf-gcc -std=c99 -O2 -fno-exceptions -g -Ispu_utils yuv2rgb/spu_yuv2rgb.c -o spu_yuv2rgb

spu-elf-gcc -std=c99 -O2 -fno-exceptions -g -Ispu_utils yuvscaler/spu_yuvscaler.c -o spu_yuvscaler

su and make install:
localhost spu-medialib # make install
mkdir -p /usr/local/bin /usr/local/include /usr/local/lib64

cp -v spu_yuvscaler spu_yuv2rgb /usr/local/bin/

`spu_yuvscaler' -> `/usr/local/bin/spu_yuvscaler'

`spu_yuv2rgb' -> `/usr/local/bin/spu_yuv2rgb'

cp -v libspuml.a /usr/local/lib64/

`libspumll.a' -> `/usr/local/lib64/libspuml.a'

cp -v spu_utils/spu_control.h yuv2rgb/yuv2rgb.h yuvscaler/yuvscaler.h /usr/local/include/

`spu_utils/spu_control.h' -> `/usr/local/include/spu_control.h'

`yuv2rgb/yuv2rgb.h' -> `/usr/local/include/yuv2rgb.h'

`yuvscaler/yuvscaler.h' -> `/usr/local/include/yuvscaler.h'

cp -v ../libfb/libfb.h /usr/local/include/

`../libfb/libfb.h' -> `/usr/local/include/libfb.h'



Patch mplayer and then make normally with --enable-fbdev_spu added to configure:
[email protected] ~/mplayer $ ./configure --enable-mga --enable-joystick –enable-fbdev_spu

Set appropriate video mode:
$ ps3videomode -v 3 -f

Run mplayer with -vo fbdev_spu and -dr for direct rendering and -double for double buffering:
$ mplayer -vo fbdev_spu:options video.mpg -dr -double

options=noscale & full
noscale forces no scaling whatsoever
full forces video to largest size for current screen res



More info and patches for testing to follow! :)
wgarrett
Posts: 4
Joined: Mon Sep 17, 2007 11:20 am
Location: Columbia, SC USA

Re: mplayer video output (vo)

Post by wgarrett »

...Update...

Have provided copies of the patch to unsolo for review. With his feedback, a few things have already been corrected.

Fixed:
implemented a workaround to prevent scaler crashes
buffers changed to be aligned by 16 - fixed strange scaling artifacts

Bugs & additional todo:
need to center image in screen (currently at 0x0 – upper left)
implement range checking for framebuffer – might cause a bad crash if you force noscale and video is too large for framebuffer. With scaling enabled (default), the vo will adjust the size down to within the framebuffer's limits
wgarrett
Posts: 4
Joined: Mon Sep 17, 2007 11:20 am
Location: Columbia, SC USA

Correction

Post by wgarrett »

Correction of earlier post:

This:
Some video codecs WON'T double buffer (matroska formats?)
Some video broken if you don't double buffer (IPB thing – read code)

Should have been:
Some video codecs WON'T direct render (matroska formats?)
Some video broken if you don't direct render (IPB thing – read code)
Protheus
Posts: 5
Joined: Sat Sep 01, 2007 6:31 am

Re: mplayer video output (vo)

Post by Protheus »

wgarrett wrote: I had to make some changes to spu-medialib to make it all work:


More info and patches for testing to follow! :)
Hi, can you release the work you have done so far? I like to support you in your affords ... but atm I am a little blind folded.

Thanks
Protheus
unsolo
Posts: 155
Joined: Mon Apr 16, 2007 2:39 am
Location: OSLO Norway

Post by unsolo »

found some bugs im trying to clear out on the yuv2argb conversion and the yuv420 scaler

figured i might as well do an attempt to integrate the two into one.
Don't do it alone.
unsolo
Posts: 155
Joined: Mon Apr 16, 2007 2:39 am
Location: OSLO Norway

Post by unsolo »

Hi again.

I made a integrated yuv420 scaler and argb converter in one spe, it seems to be working well enough for >> 24FPS for now (many ways to make it faster).

However there are some edge artifacts when scaling to 1080p tho all other modes does not have these according to my initial studies i think this is a buffer issue somewhere i have overlooked.
Don't do it alone.
wgarrett
Posts: 4
Joined: Mon Sep 17, 2007 11:20 am
Location: Columbia, SC USA

mplayer vo using spu-medialib

Post by wgarrett »

I've sent the latest copy of the vo to unsolo for testing. It's still rough and needs a lot of work, but it seems to work.

I don't have svn access yet, so if unsolo tests it, and he wants to make it available on svn, it's ok with me.

Here's the current version of the README:

Notes:
needs to do direct rendering, but you don't have
to specify -dr on the command line because vo will
enable it automatically if it can

non dr video broken - know why, but haven't gotten there yet

needs to double buffer, but you don't have to specify that either (-double)

doesn't do windows - takes over framebuffer for now

h264 issues:
currently not working
video currently doesn't direct render unless u post process with -vf pp
broken on PS3 (regardless of vo) - too slow & audio strange
try with -demuxer 35 -lavdopts fast:threads=2 for improvement, but
still not usable
try with -vo null and still broken (see, it's not vo's fault :) )

configure now autodetects fbdev_spu

works with:
'f' for fullscreen scaling toggle
'space' for pausing
'. for single frame stepping

use -vo fbdev_spu:snapshot to save a .yuv file of current
buffers on pause

Dependencies:
spu-medialib & ps3fb must be installed
must be able to find:
libspe2.h
spu-medialib/spu_control.h
spu-medialib/yuv2argb_scaler.h
ps3fb/libps3fb.h
libspu-medialib.a
libps3lib.a

Installation:
install ps3fb
install spu-medialib
get & patch fresh mplayer
svn co svn://svn.mplayerhq.hu/mplayer/trunk mplayer
cd mplayer & patch:
$ patch -p0 < mplayer-vo_fbdev_spu.patch
patching file libvo/video_out.c
patching file libvo/vo_fbdev_spu.c
patching file configure
make normally (./configure; make; make install)

Usage:
$ ps3videomode
$ mplayer -vo fbdev_spu /lost/video/watchme.mpg
unsolo
Posts: 155
Joined: Mon Apr 16, 2007 2:39 am
Location: OSLO Norway

Post by unsolo »

Installation guideline moved to a separate thread.

http://forums.ps2dev.org/viewtopic.php?t=9187
Don't do it alone.
Chinaphoro
Posts: 47
Joined: Mon Jan 03, 2022 10:15 am
Location: http://product-of-china.cf/
Contact:

-

Post by Chinaphoro »

I trimmed an .avi video and the output file plays like it is in fast forward. I dont see anybody else mentioning this problem on the forum. Is anybody else having this issue?
Post Reply