Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

aha! Victory is Mine!

Sign in to follow this  


Having won the fight compiling and linking my library together I set about today getting it intergrated into a test application... step forward a spinning cube! [grin]

Turns out, despite being a dll, the freeglut dll compiled with the multithread runtime not the multithread dll runtime, so a quick compiler and run later and we had... a crash.

OK, not a stunning start, however it was a start [smile]

Some investigation and we see why we shouldn't just ignore bits of code in example [grin]
Turns out the Theora library builds up frames until it has 'enough' to warrent a flush to a stream at which point off it goes. I kinda ignored this which lead to a crash as I tried to fwrite() from a bad memory location [grin]

One code fix later and it didn't crash... but the video didn't play [sad]
Another quick look at the code and we notice.. oppps, we aren't encoding based on the right sizes [grin], change 3 varibles later... compiler, run... no crash, video file made... but it's just blue [oh]

There follows a 20mins of confusion while I try to work out whats going on, including moving the cube about incase I'd done something daft and it was just encoding a corner.

No dice.

Another look at the code and I spot the problem;
In the RGB => YUV conversion loop I loop based on pixels and maintain a second count of the offset into the RGB buffer.. or so I thought, turns out having RGB=3 in the for-loop didn't advance the buffer.. yep, we were constantly encoding pixel 2, heh

One fix of that later, recompile, run, end and I present to you; test.ogm.. huzzah!
(requires something which will play back Ogg Theora video files to view)
[edit:ok, so gamedev's servers dont' seem to like ogm files, so I've uploaded it else where]

Spinning cubes for the win, heh

There is one slight problem with it, which isn't really visable in that video... it's upside down [grin]
Due to the way things are readback via glReadPixels top becomes bottom, all I need to do is flip it in the RGB => YUV converter, but right now I can't be bothered as i'm going out in a bit [smile]

So, in effect it work, which leaves me with the following todo list;
- make it multithreaded
- change from C IO to C++ IO
- improve interface to allow for more customisation
- Speed up the various conversions routines
- Sound

The final one is waaaaaay down on my list of things todo, as frankly I'm not even sure how I'd go about doing the sound capture and right now I've not got anything which requires sound in it [smile]

Still, this turned out to be easier than I thought, which is always a bonus... I might have to speed up the RGB=>YUV stuff, atm it's a function I pulled from MSDN, which while it's quick as it works on ints a lookup table might well be faster.

Also, as part of the conversion step we have to reduce the UV data to 1/4 of what it was (Theora uses a 4:2:0 encoding scheme), which right now involves reading back 4 pixels and finding the average and outputting that as a single pixel; SSE/MMX might make a nice dent in it performance wise, however that's another 'once the rest is done' thing.
Sign in to follow this  

1 Comment

Recommended Comments

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!