PDA

View Full Version : Performance rendering video



whisper
11-26-2003, 10:39 AM
Hello,

I'm currently rendering video using a texture and then just displaying the texture using glQuad.

I'm looking for the right settings, but I'm not sure wht should be changed. Currently here is what I do:

//hints
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
glHint(GL_POINT_SMOOTH_HINT, GL_FASTEST);
glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST);
glHint(GL_POLYGON_SMOOTH_HINT, GL_FASTEST);
glHint(GL_FOG_HINT, GL_FASTEST);


// create the texture
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glEnable(GL_TEXTURE_RECTANGLE_NV);
glGenTextures(1, &m_videoTexture);
glBindTexture(GL_TEXTURE_RECTANGLE_NV, m_videoTexture);
BYTE* black_frame = (BYTE*)malloc(width*height*16*sizeof(BYTE));
memset(black_frame, 0, width*height*16*sizeof(BYTE));
glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_SHORT, black_frame);
glTexParameteri(GL_TEXTURE_RECTANGLE_NV,GL_TEXTURE _MIN_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_NV,GL_TEXTURE _MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_NV,GL_TEXTURE _WRAP_S,GL_CLAMP);
glTexParameteri(GL_TEXTURE_RECTANGLE_NV,GL_TEXTURE _WRAP_T,GL_CLAMP);
free(black_frame);

Is it necessary to create this black frame ??
After this, I just use glTexSubImage2D to copy the video into the texture.

Is there some improvements that can be made ?

TIA

wpr

Mazy
11-26-2003, 12:44 PM
a think a NULL pointer should do..

Dirk
11-26-2003, 12:51 PM
Originally posted by whisper:
Hello,

glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_SHORT, black_frame);


I'm not sure about texture recxtangle, but in general GL_UNSIGNED_BYTE gives the best performance, better than GL_UNSIGNED_SHORT. Depending on your platform, GL_ABGR might be better, too, but the difference shuld be pretty small nowadays.

You can also do fancy stuff with pixel data range, but I don't know how effective that really is. I know there is an example out of nVidia that shows how to most effectively render video using PDR and other tricks for colorspace conversion, but I haven't gotten my hands on it yet... Does anybody have it?

kohn
11-27-2003, 01:33 AM
Where have you find an example for using PDR? I can't find anywhere?

whisper
11-27-2003, 02:35 AM
Hi,

I tried to use GL_ABGR_EXT but I got a "invalid enumerant error"

wpr.

jwatte
11-27-2003, 07:57 AM
The high-performance option is "GL_BGRA" which is core in version 1.2 and up. What version are you getting from GL_VERSION? What is the vendor in GL_VENDOR? If you're getting the Microsoft generic implementation, don't expect any performance.

To initialize a texture image that you will later overwrite using TexSubImage(), the spec says you can pass NULL as last argument to TexImage2D().

GL_UNSIGNED_SHORT is very unlikely to be accelerated by current hardware. GL_UNSINGED_BYTE/GL_BGRA is the most likely combinations. Others include the "baked" formats of 5_6_5_REV or _8_8_8_8_REV (assuing x86 host CPU).