[gst-devel] best way to internally represent an image

Florin Andrei florin at andrei.myip.org
Mon Feb 25 00:33:34 CET 2008

(apparently offtopic, but bear with me, you'll see it's not)

I'm writing a 3D raytracer to analyze relativistic phenomena. The 
raytracer must be able to draw the 3D scene in real time, or to parse a 
script and then generate a movie based on the scripted movements of the 
camera. I'm in a very early stage, still planning the high level stuff. 
 From a user's perspective, it will superficially resemble Celestia 
(display a view of the "cosmos" that the user can navigate with the 
joystick or keyboard):


I think I may use Gstreamer to generate the movies.

But anyway, here's the question:
I need to decide on the internal format to represent the image being 
rendered. It will probably be some kind of bitmap, a matrix of pixels. 
But I have a hard time deciding between RGB, YUV, and all that stuff.

I am tempted to use a matrix of pixels, each pixel being a C structure 
like this:

struct pixel
	unsigned char red;
	unsigned char green;
	unsigned char blue;

That would be 24 bit RGB, I guess. I like it because it feels "natural", 
and it's trivial to come up with algorithms that, e.g., give a blue tint 
("blue shift"), etc.

But I need to decide on a format that will make it easiest to accomplish 
the 2 main goals of the program's output:

1. Project an interactive 3D scene on the screen in real time using SDL 
or Xv, or whatever fast and portable method I can find

2. Interface with a program or a library that can dump a movie on the 
disc in some nice universal format (MPEG2, MPEG4, etc, 480p, 1080p, or 
user-defined such as 1024x768, etc.) regardless of whether I'll actually 
use Gstreamer for that purpose or not (but the likeliest candidate at 
this moment is Gstreamer, it's really nice and powerful)

Speed is crucial, as the project has some pretty ambitious goals (HD 
resolutions up to 1080p, real time display for as high resolutions as 
possible - ideally for 1080p on very good hardware, or whatever can be 
achieved with the best hardware today). So choosing the internal image 
representation has to take that in consideration.

I'm not an expert in video programming. I'm not even a professional 
programmer. I'm just a hobbyist. So I would appreciate any advice from 
experienced people.

So - which internal format would you use for the image?


Florin Andrei


More information about the gstreamer-devel mailing list