pantson.Theora v2.1

BlitzMax Forums/BlitzMax Programming/pantson.Theora v2.1

PantsOn(Posted 2008) [#1]
Hi

I've released v2.1 of the Theora movie library.
In this version I've fixed the ghosting of images when the movie loops.
(sorry about the delay getting this out)

Download link in signature.


plash(Posted 2008) [#2]
Cool, is it cross-platform? (I don't currently have a use for it - yet, so I didn't take a peek)


PantsOn(Posted 2008) [#3]
it is cross platform..but you will just have to compile the mod on linux or mac.
I have only included the windows compiled libs.

PS it doesn't do sound, but there is an example in the archive on how to sync sound and picture.


Lord Danil(Posted 2008) [#4]
So it is much better.
But, only 13fps while playing video 1024*512 (on 2*3.0 GHz processor!).

While it is not enough of it for games.
MS MediaPlayer plays this video on full speed.


PantsOn(Posted 2008) [#5]
unfortuantely it has to convert all YUV info to RGB (so that Blitzmax can display it) Thats what takes so long...
Now if BlitzMax/OpenGL had YUV pixmaps instead...


Brucey(Posted 2008) [#6]
Now if BlitzMax/OpenGL had YUV pixmaps instead...

Wouldn't it be possible to make a version that does?


PantsOn(Posted 2008) [#7]
not sure Brucey... i'm not an opengl expert ;-)
This guy was taking about it.. but its all greek to me
http://propirate.net/oracle/archives/2006/03/05/yuv-on-gl/

PS I'm not greek ;-)


PantsOn(Posted 2008) [#8]
This thread strats to talk about a fragment shader, but I would not know where to start.
http://www.fourcc.org/fccyvrgb.php

I have used the page for the equatiuon to convert YUV to RGB. To make it fastest I've used lookup tables, rather than calculating every pixel.

Obviously fragment shaders are the way forward, but I wouldn't know where to start


Brucey(Posted 2008) [#9]
And of course your card would need to support it too.

But I see what you mean... :-)


Lord Danil(Posted 2008) [#10]
2PantsOn:
>To make it fastest I've used lookup tables, rather than calculating every pixel.

And you tested speed with direct calculation and under the table?
There is an opinion that access to memory borrows more time than calculation.

Can you make a choice between table-based calculation and direct-calculation?

P.S. If colors=false, speed up to 25-27fps (native video fps=30)


PantsOn(Posted 2008) [#11]
I have tested the speeds of both and the lookup tables do work faster.
Greyscale is a bit fatser as it has to lookup and calculate less then color mode.

Heres the color
			tmp = (Y[ypoint]<<8) + U[upoint];
			r = yuv_r[tmp];

			tmp = (Y[ypoint]<<16) + (U[upoint]<<8) + V[vpoint];
			g = yuv_g[tmp];

			tmp = (Y[ypoint]<<8) + V[vpoint];
			b = yuv_b[tmp];



Heres the greyscale
			g = yuv_bw[Y[ypoint]];


The other slow down is uploading the new pixmap to the image/gfx card every time it needs to be drawn.

I have optimised this as far as possible within 'standard' BlitzMax without using any OpenGL fixes that there may be.


robw(Posted 2008) [#12]
Thanks for this, pantson -- I had posted about the ghosting w/ v2.0, but this new version is working really well


PantsOn(Posted 2008) [#13]
sorry for the delay robw, glad it works for you.


DannyD(Posted 2008) [#14]
Does anyone have sample code that imports the library and plays a vid? It would be much appreciated. Thanksl.


plash(Posted 2008) [#15]
You can find example code in the 'project' folder from the download.

Here is one:
Strict

' import theora v2.0
Import pantson.theora

Local m:Ttheora = OpenTheora("dice.ogg")

' autoloop
m.autoloop = True

 'set up gfx
Graphics 800,600,0

' create pixmap size of theora movie
Local p:TPixmap = CreatePixmap(TheoraWidth(m),TheoraHeight(m),PF_STDFORMAT)

' FPS vars
Local ticks:Int = 0
Local start:Int = MilliSecs()
Local fps:Int = 0

' initiate movie
StartTheora(m)

' loop
While Not KeyDown(key_escape)
	' basic fps equation
	fps = (ticks*1000)/Max(1,(MilliSecs()-start))
	
	' process all theoras and check for update
	If ProcessTheora()
		' if an update occoured, draw movie.
		DrawTheoraPixmap(m,p) 
		
		' draw pixap
		DrawPixmap p,0,0	
		
		' display FPS
		DrawText fps,20,20
		
		ticks:+1
		Flip
	EndIf

Wend