Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using YUV and RGB textures together



Hi Simon,
we use RGB and YUV textures together, and haven't hit this problem, though we've seen some other issues in the past. One thing we don't do, that it looks possible you're doing, is do a glTexImage2D on the same texture ID with both RGB and YCBCR formats, without a glDeleteTextures()/glGenTextures() between them. This shouldn't matter in theory, in practice if you're not doing that, I'd give it a try.


We've also noticed some odd interactions between the client storage extensions, and some drivers. I would try removing that, just to see if it makes a difference. Just as a note, we don't use the unpack attributes for what we're doing.

thanks,
	Pete

On 20 Apr 2005, at 22:15, Simon Wilson wrote:

Dennis,

I’ve tried a range of things: only specifying GL_UNPACK_ROW_LENGTH for the
YCbCr image, setting GL_UNPACK_ROW_LENGTH to 0 or the image’s pixel with
for the other formats, setting GL_UNPACK_CLIENT_STORAGE_APPLE to GL_FALSE,
and probably a few other things as well. In all cases, only the upper half
of any image with RGB, RGBA or grayscale pixel formats is show, stretched
over the whole quad. If I remove all calls to glPixelStorei() from the
application, this happens to all image formats.


Here's a brief rundown of the code I have now:

SetTextureData( ... )
{
  glBindTexture( GL_TEXTURE_RECTANGLE_EXT, gltex );

glTextureRangeAPPLE( GL_TEXTURE_RECTANGLE_EXT, size, data );
glTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_STORAGE_HINT_APPLE,
GL_STORAGE_SHARED_APPLE );
glTexParameterf( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_PRIORITY, 0.0f );


  glTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MIN_FILTER,
GL_LINEAR );
  glTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MAG_FILTER,
GL_LINEAR );
  glTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_S,
GL_CLAMP_TO_EDGE );
  glTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_T,
GL_CLAMP_TO_EDGE );

if( type == RGB )
{
glPixelStorei( GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE );
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
glTexImage2D( GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGBA, GetWidth(),
GetHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, data );
}
else if( type == RGBA )
{
glPixelStorei( GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE );
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
glTexImage2D( GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGBA, GetWidth(),
GetHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, data );
}
else if( type == YCrCb )
{
glPixelStorei( GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE );
glPixelStorei( GL_UNPACK_ROW_LENGTH, GetWidth() * 2);
glTexImage2D( GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGBA, GetWidth(),
GetHeight(), 0, GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE, data );
}
else if( type == GRAYSCALE )
{
glPixelStorei( GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE );
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
glTexImage2D( GL_TEXTURE_RECTANGLE_EXT, 0, GL_LUMINANCE, GetWidth(),
GetHeight(), 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data );
}
}


void draw()
{
  glBindTexture( GL_TEXTURE_RECTANGLE_EXT, tex );
  glBegin(GL_QUADS);
    glTexCoord2f( 0, 0 );        glVertex3f( 0, h, 0.1 * i );
    glTexCoord2f( w, 0 );        glVertex3f( w, h, 0.1 * i );
    glTexCoord2f( w, h );        glVertex3f( w, 0, 0.1 * i );
    glTexCoord2f( 0, h );        glVertex3f( 0, 0, 0.1 * i );
  glEnd();
}

I'm really quite stumped now. I'm reasonably sure that the code that
generates the RGB data from the YCbCr input is correct (it's from another
program, and runs fine there), and messing with the texture coordinates
shows that only half the image is being loaded into the texture.


I figure I've either not set something up, or I'm doing something
incorrectly. But I have no idea which. Thanks for the replies, and I hope
somebody can point me in the right direction...


- Simon Wilson

On 21/4/05 7:56 AM, "Dennis Piatkowski"
<email@hidden> wrote:

Maybe I missed something, but it would seem you need to call glPixelStorei(
GL_UNPACK_ROW_LENGTH,...) before each call to glTexImage2D() for each of the
textures. I am not 100% certain, but I think this parameter is bound with the
rest of the texture state in glBindTexture(). Even if not, just making sure
to call glPixelStorei() after each glBindTexture() should garantee a fix.


- Dennis

=================================== iChat: DrakkenWulf1 (AIM)
http://DrakkenWulfEnterprises.com


On Apr 20, 2005, at 4:23 PM, email@hidden wrote:

I'm looking for a way to display both a YUV image extracted from QuickTime
(using either a sequence grabber or a movie controller) and an RGB image
generated by my processing code. I can display the YUV data correctly using
GL_YCBCR_422_APPLE inside a GL_TEXTURE_RECTANGLE_EXT texture. The problem
currently appears with the use of glPixelStorei( GL_UNPACK_ROW_LENGTH, width
* 2 ). With 'width*2', I get the correct height for the output YUV image, but
the RGB texture data is only then half the height. Going for just 'width'
makes the RGB image work fine, but only provides half the YUV image. Each
texture is rendered onto a single quad with varying transparency so that I
can see the image through the marks made by the processing code.


I've seen a bit about YUV -> RGB shaders, and I'm curious whether I need to
go down this path, but I can't see how that solves the texture unpacking
problem. I don't really want to generate the RGB image as YUV as well.


Does anybody have any suggestions? I'm stumped.

- Simon Wilson


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/mac-opengl/ email@hidden


This email sent to email@hidden



_______________________________________________ Do not post admin requests to the list. They will be ignored. Mac-opengl mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/mac-opengl/email@hidden

This email sent to email@hidden
References: 
 >Re: Using YUV and RGB textures together (From: Simon Wilson <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.