Pvf(PspVideoFormat) Encoder/Playback library.

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Pvf(PspVideoFormat) Encoder/Playback library.

Post by Kojima »

Hey, hope you don't mind me posting this here instead of the release forum(Which is like tumbleweed city atm) as most other people release there psp libs here. :)


I needed video for my app, and wasn't too keen on porting a complex library from windows, squashing bugs etc so I decided to write my own, so this was born. Pvf. It includes a windows based command line encoder which converts avi to pvf and it includes a psp C++ based(uses classes so no c I don't think) playback library.


http://www.savefile.com/files/9354107 <Encoder (6.7mb. My god, it's full of dlls! Windows only - Ask for source if you wish to port )

Instructions: Simply drag and drop your windows avi file over the app and it will produce the pvf equilivent for you, informing you of it's progress.

http://www.savefile.com/files/5185915 < PvfLib (NOTE:Tested on 1.5firmware only. I cannot be sure it works on older/new revisions)

http://www.savefile.com/files/3037812 < Psp xxploited demo for 1.5 firmware.

The playback library generates a _frameRgb pointer for each frame which is in pspGL format. (I.e 3 bytes, rgb, 0-255 each )

I've tested it within my 3d engine and it playsback perfectly and pretty fast.

The library uses zlib for both compression and decompression, although you only require it to be installed in your psp environment. the pc side is an exe so not required in cyngwin.
cypher35
Posts: 1
Joined: Thu Jul 13, 2006 4:32 pm
Location: right behind you!!
Contact:

Post by cypher35 »

I would love to take a look at your source code if you wouldn't mind...

cypher35 at gmail dot com
-or-
rapidshare/megaupload/savefile if you prefer
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

Sent.
ADePSP
Posts: 58
Joined: Thu Jul 13, 2006 9:07 pm

Post by ADePSP »

Would someone please be kind enougth to explain how I install and use this...? I'm new to making homebrew on 1.5 but have cygwin and the PSPDEV setup and working...

I'm porting my Pimp My Garage web tool to work on the PSP directly and have a lot of it done... I just need to be able to play video media at certain points...

A short tutorial would be excellent and help me a lot...

Thanks
ADePSP
Creator of CheatSync and Pimp My Garage for the CheatDevice by edisoncarter
http://www.cheatsync.net
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

There is no installation as such, I never made it into a lib. (No real reason why, just didn't)

So basically, just open up the source/example and compile it, or a much better idea would be to cut and paste it into your engine, it's a really short piece of code overall so as long as you've zlib installed it should work out of the box.

Let me know if you run into any problems, and I'll try to explain it better.
ADePSP
Posts: 58
Joined: Thu Jul 13, 2006 9:07 pm

Post by ADePSP »

Kojima wrote:There is no installation as such, I never made it into a lib. (No real reason why, just didn't)

So basically, just open up the source/example and compile it, or a much better idea would be to cut and paste it into your engine, it's a really short piece of code overall so as long as you've zlib installed it should work out of the box.

Let me know if you run into any problems, and I'll try to explain it better.
Thanks i'll give it a go (after this ToolChain installs "just rebuilt PC and god this takes time)"... I probably will need more help but thanks a lot... I'll see if I can work it out...

ADe
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

No problem.

Found a serious bug in the encoder, seems I left in some hard-coded stuff that basically overides the input arguments and always loads the avi called "Face2.avi"
so if you've d/l and ran into any problems, it's probably that. I'll release a updated version when I'm not so tired.
ADePSP
Posts: 58
Joined: Thu Jul 13, 2006 9:07 pm

Post by ADePSP »

Kojima wrote:No problem.

Found a serious bug in the encoder, seems I left in some hard-coded stuff that basically overides the input arguments and always loads the avi called "Face2.avi"
so if you've d/l and ran into any problems, it's probably that. I'll release a updated version when I'm not so tired.
OK, one big problem... Where is this example...? The links in your first post are for the encoder util, a single file called Pvflib.cc and a compiled demo of the code in action...

Am I missing something...?

ADe
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

No you're not, the pvf lib loads the test pvf and grabs each frame, it's down to you to write a renderer.
ADePSP
Posts: 58
Joined: Thu Jul 13, 2006 9:07 pm

Post by ADePSP »

Kojima wrote:No you're not, the pvf lib loads the test pvf and grabs each frame, it's down to you to write a renderer.
I see... Any chance of an example (very basic) project that does that with instructions on how to install whatever renderer I may need...?

Sorry to be such a n00b but it's hard not to be when you are learning something... :D

Thanks again,
ADe
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

I'll be releasing an open source pvf media player with a video renderer shortly so you can learn from that, it's very easy to follow code as I prefer libraries to aid development, not hinder them.

It also demos the gui lib of the up coming Raptor Engine of mine (/plug)
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

I've wrote a new codec, which results in 10x smaller files than pvf. it still uses zlib, but it's got a much fanicer encoder/format. this one has cell and frame indexing allowing real time catching of cells for massive speed increases.

Will release with media player before I go to bed tonight, so not long.
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

Image

Image

If you see two images, that' just I wasn't sure if it was working or just displaing my cache so I played it safe.

that's pva media viewer, using Raptor's 2d and gui engines. The video display using canvas which have raw surfaces with sync abilities. (Internally they are textures)

Just putting together a file including the new encoder.
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

very awesome brother
10011011 00101010 11010111 10001001 10111010
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

Thanks dot, I'll be releasing a demo soon, just busy working on the 3d engine for my game atm.
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

take your time ...do as you must
im looking forward to see if this format
would be memory efficient and cpu effecient
for ingame cutscenes and game intro animations
10011011 00101010 11010111 10001001 10111010
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

Seeing this really makes me want to jump into making my own codec with some of my h264 knowledge I gathered some time ago and on the way gaining some experience with VFPU (it is really very well suited for codec stuff) :) Keep it up, this has potential.
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

I started on a simple streaming one, then we got PiMP Streamer!
I went from
RGB32->swizzled RGB->YUV->YV12->LZO
That got me down to 2Mbits. Still too much to stream, but getting there.
Other things I mean to try
Adding a quantisation to UV and then RLE before LZO compression.
And to get to MPG1 style compression you need DCT and motion compensation.

Jim
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

Raphael wrote:Seeing this really makes me want to jump into making my own codec with some of my h264 knowledge I gathered some time ago and on the way gaining some experience with VFPU (it is really very well suited for codec stuff) :) Keep it up, this has potential.
If you do the codec, I'll do the media player using raptor :)

I would like to try dct and so on but my encoder language (Blitzmax) has no inline asm or anything to really speed up the encoding process.
pva encoding compared of pvf is painfully slow.
alatnet
Posts: 14
Joined: Wed Oct 19, 2005 8:57 am

Post by alatnet »

Kojima, I like pvflib and im thinking bout integreating it to luaplayer so that i can use it for my mmo game that im working on. Im just wondering if there is a way to have it work with yeldarb's c\c++ graphics thing cus im not that keen with pspGL. I've been kinda studying the src code of the pvflib and im sorta having some doubts that i can integrate it with luaplayer.
You said that you'd be releasing an open source pvf media player with video render so that ppl can learn from it, yet, i have not yet seen it. I really want to see how it works. It's been a month since you said that, when are you going to release it?
"Every team needs an idealistic person (whether they are a noob or a pro), my team doesn't have one cus im the idealistic founder." - me
Image
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

No I'm afraid I won't be releasing it.

I'm happy for you include it luaplayer, but I don't know much about that guy's 2d library, never seen it before or even know where to get it.(I've only used luaplayer briefly to try out some demos)

But as long as it can display a raw buffer in rgb format (1 byte = one component in the range of 0 to 255) then it can work.

but seriously I suggest grabbing raptor alpha 3 and using the new pva video format. its faster, better compressed etc. I can hook you up with the pva encoder if you like.

Here's the source though.

Code: Select all

const int m_play = 1,m_rew =2,m_ff = 3,m_pause = 4,m_stop = 5;
int main&#40;int argc, char **argv&#41; 
&#123;	
	pspDebugScreenInit&#40;&#41;;
	
	printf&#40;"Test.\n"&#41;;
	
	InitRaptor&#40;&#41;;


	Joypad *joy = new Joypad;

	//printf&#40;"C&#58;/Dir/OtherDir/test.bmp\n"&#41;;
	//char * buf = &#40;char *&#41;malloc&#40;1&#41;;
	//buf&#91;0&#93; = 92;
	//printf&#40; "C&#58;\Dir\OtherDir\Test.bmp\n"&#41;;
	//printf&#40;"&#58;&#58;\n"&#41;;
	

	//Window * tst = new Window;

//	Pvf *video = new Pvf&#40;"tst.pvf"&#41;;
	
	
	SetDefaultStyle&#40; new GradientStyle &#41;;
	Display *sys = new Display&#40;argc,argv&#41;;
	Pen *pen = new Pen;
	
	
	
  /*
	Prefab *prefab = new Prefab;
 	Camera *vcam = Factory->ProduceCamera&#40;&#41;;
 	Entity *box = prefab->CreateCube&#40; 10 &#41;;
 	vcam->Position&#40;0,20,-40&#41;;

	Renderer->_ActiveCam = vcam;
	box->Position&#40;0,0,0&#41;;
	box->Rotate&#40;0,0,0&#41;;
	vcam->PointAt&#40;0,0,0&#41;;
	float bx,by;
	bx=0;
	by=0;
	float cp=0,cy=0;
 	*/
 	
 	/*
 	sys->Draw2D&#40;&#41;;

	 	
 
 	Cursor *curs = new Cursor&#40; new Texture&#40;"NeHe.bmp",BMP&#41; &#41;;
 	Gui *mgui = new Gui&#40; curs,joy &#41;;
 	mgui->SetBackground&#40; new Texture&#40;"back1.bmp",BMP&#41; &#41;;

  Body *view = new Body&#40; 40,20,400,170,"Output"&#41;;
  Canvas *vsurf = new Canvas&#40; 5,5,390,160,256,256 &#41;;
  view->Attach&#40; vsurf &#41;;
	Body *cpanel = new Body&#40;0,200,478,70,"Controls"&#41;;
	Button *ok = new Button&#40;20,20,80,30,"OK"&#41;;
	ok->SetBounds&#40; 0,20,458,20 &#41;;
	ok->SetScroll&#40; true,false &#41;;
	//Label *lab = new Label&#40;,20,"Playback"&#41;;
	SliderH *slide = new SliderH&#40; 5,2,458,20,"Z"&#41;;
	cpanel->Attach&#40; slide &#41;;
	
	slide->SetRange&#40; 10 &#41;;
	slide->SetValue&#40; 10 &#41;;
	
	Texture *rewimg = new Texture&#40;"rewind.bmp",BMP&#41;;
	Texture *fasimg = new Texture&#40;"fastf.bmp",BMP&#41;;
	Texture *pauseimg = new Texture&#40;"pause.bmp",BMP&#41;;
	Texture *playimg = new Texture&#40;"play.bmp",BMP&#41;;
	Texture *stopimg = new Texture&#40;"stop.bmp",BMP&#41;;
	
	Label *info = new Label&#40; 320,5,"PVA MediaPlay"&#41;;
	Label *file2 = new Label&#40; 320,25,"Face2.PVA"&#41;;
		
	
	Button *rewind = new Button&#40; 5,30,40,20,"" &#41;;
	rewind->SetImage&#40; rewimg &#41;;
	Button *play = new Button&#40; 48,30,40,20,"" &#41;;
	play->SetImage&#40; playimg &#41;;
	Button *fastforward = new Button&#40;91,30,40,20,"" &#41;;
	fastforward->SetImage&#40; fasimg &#41;;
	Button *pause = new Button&#40; 134,30,40,20,"" &#41;;
	pause->SetImage&#40; pauseimg &#41;;
	Button *stop = new Button&#40; 177,30,40,20,"" &#41;;
	stop->SetImage&#40; stopimg &#41;;
	
	cpanel->Attach&#40; rewind &#41;;
	cpanel->Attach&#40; play &#41;;
	cpanel->Attach&#40; fastforward &#41;;
	cpanel->Attach&#40; pause &#41;;
	cpanel->Attach&#40; stop &#41;;
	cpanel->Attach&#40; info &#41;;
	cpanel->Attach&#40; file2 &#41;;
		
	mgui->AttachGadget&#40; cpanel &#41;;
	mgui->AttachGadget&#40; view &#41;;
	
 	Font *fnt = new Font&#40;"fnt1.bmp",32,32&#41;;
 	FontRenderer->SetActive&#40; fnt &#41;;
 	FontRenderer->SetColor&#40;1,1,1&#41;;
 	//	GLuint vidtex;
 		//glGenTextures&#40;1, &vidtex&#41;;
   // glBindTexture&#40;GL_TEXTURE_2D,vidtex&#41;;   // 2d texture &#40;x and y size&#41;
			
   //	glTexParameteri&#40;GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR&#41;; 
   //	glTexParameteri&#40;GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR&#41;; 
						
    //glTexImage2D&#40;GL_TEXTURE_2D, 0, 3, 256,256, 0, GL_RGB, GL_UNSIGNED_BYTE, video->_framergb&#41;;
   // glBindTexture&#40;GL_TEXTURE_2D,0&#41;;
 
	Pva *video = new Pva&#40;"face2.pvf"&#41;;
	//file->SetText&#40;"Face2.pvf"&#41;;
	slide->SetRange&#40; video->_numframes &#41;;
   int butstate = 0;
	int in=false; 
	SoundEngine *sfx = new SoundEngine;
	Sound *snd = new Sound&#40;"ms0&#58;/sound.wav"&#41;;
	int ps =0;
	*/
	

	Entity *ent = LoadB3D&#40; &#40;const char *&#41;"level.b3d",NULL &#41;;
	if&#40;ent==NULL&#41;
	&#123;
		Logger->Log&#40;"Loadb3d returned null entity.\n"&#41;;
	&#125;
	else
	&#123;
		Logger->Log&#40;"Loadb3d returned valid entity.\n"&#41;;
	&#125;


	int mode;
	mode = m_play;
 	while&#40;1&#41;
  &#123;
  	
  	switch&#40; mode &#41;
  	&#123;
  		case m_play&#58;
  			video->NextFrame&#40;&#41;;
			
			  break;
			case m_ff&#58;
				video->_frameindex+=4;
				if&#40; video->_frameindex>&#40;video->_numframes-1&#41; &#41; 
				&#123;
					video->_frameindex=0;
				&#125;
				video->SetFrame&#40; video->_frameindex &#41;;
				break;
			case m_rew&#58;
				video->_frameindex -= 4;
				if&#40; video->_frameindex<0 &#41;
				&#123;
					video->_frameindex=&#40;video->_numframes-1&#41;;
				&#125;
				video->SetFrame&#40; video->_frameindex &#41;;
				break;
		&#125;
		slide->SetValue&#40; video->_frameindex &#41;;
	 	vsurf->SetRawAndSync&#40; video->_framergb,false &#41;;
  	//vcam->Rotate&#40; vcam->Pitch&#40;&#41;,vcam->Yaw&#40;&#41;,vcam->Roll&#40;&#41; &#41;;
 		joy->Update&#40;&#41;;
 		if&#40; &#40;joy->_triangle == true&#41; &#41;
 		&#123;
 			if&#40; ps == false &#41;
 			&#123;
 			snd->Play&#40;&#41;;
 			ps = true;
 			&#125;
 		&#125;	
 		else
 		&#123;
 			ps=false;
 		&#125;
 		//sfx->Update&#40;&#41;;
  	glClear&#40;GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT&#41;;		// Clear The Screen And The Depth Buffer
		//vcam->Move&#40;0,0,0&#41;;
	//	vcam->Other&#40;joy->_x,0,joy->_y&#41;;
		glLoadIdentity&#40;&#41;;
		
  
 		
 		//glEnable&#40;GL_TEXTURE_2D&#41;;
 		//glBindTexture&#40;GL_TEXTURE_2D,vidtex&#41;;
 		
 	//	pen->Rect&#40;0,0,480,272&#41;;
 		
 		//video->NextFrame&#40;&#41;;
 		//glTexImage2D&#40;GL_TEXTURE_2D, 0, 3, 256,256, 0, GL_RGB, GL_UNSIGNED_BYTE, video->_framergb&#41;;

 		
 		glDisable&#40;GL_TEXTURE_2D&#41;;
 		glColor4f&#40;1,1,1,1&#41;;
 		pen->Rect&#40;20,20,80,20&#41;;
 		
 		
 		
 	 	Blend_Mask&#40;&#41;;
  	
  	
  	mgui->Update&#40;&#41;;
  	mgui->Render&#40;&#41;;
  	//glEnable&#40;GL_TEXTURE_2D&#41;;
  	//fnt->_tex->Bind&#40;&#41;;
  	//pen->Rect&#40;0,0,480,272&#41;;
  	
  	
  	//FontRenderer->RenderText&#40;0,0,"Gui Test Alpha 1"&#41;;
  	int ec = mgui->CountEvents&#40;&#41;;
  	for&#40;int i=0;i<ec;i++&#41;
  	&#123;
  		Event *e = mgui->GetEvent&#40; i &#41;;
  		
  			
  			switch&#40;e->_id&#41;
  			&#123;
  				case Mouse_Enter&#58;
  					//snd->Play&#40;&#41;;
  					break;
  				case Mouse_Leave&#58;
  				
  					break;
  				case Gadget_Action&#58;
  					if&#40; e->_from == play &#41;
  					&#123;
  						mode = m_play;
  					&#125;	 				
  					if&#40; e->_from == rewind &#41;
  					&#123;
  						mode = m_rew;
  					&#125;
  					if&#40; e->_from == fastforward &#41;
  					&#123;
  						mode = m_ff;
  					&#125;
  					if&#40; e->_from == pause &#41;
  					&#123;
  						mode = m_pause;
  					&#125;
  					if&#40; e->_from == stop &#41;
  					&#123;
  						mode = m_stop;
  						video->_frameindex = 0;
  					&#125;
  					break;
  					
  			&#125;
  	
  	&#125;
  	switch&#40;e->_id&#41;
  			&#123;
  				case Mouse_Enter&#58;
  				
  					break;
  				case Mouse_Leave&#58;
  				
  					break;
  				case Gadget_Action&#58;
  					
  					break;
  					
  			&#125;
  	mgui->ClearEvents&#40;&#41;;
	
 		//Renderer->RenderScene&#40;&#41;; 	  
 		
 	//	sys->Draw2D&#40;&#41;;
		if&#40;joy->_select==1&#41;
		&#123;
			sceKernelExitGame&#40;&#41;;
		&#125;
  	if&#40; joy->_rtrigger &#41;
  	&#123;
  		screenshot&#40;"mplay"&#41;;
  	&#125;
  	glutSwapBuffers&#40;&#41;;
  &#125;

  return &#40;0&#41;;
&#125;
It uses raptor for the gui/display.
[/code]
Post Reply