Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 271125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:06:42+00:00 2026-05-12T00:06:42+00:00

I have been assigned wit the task to write a program that takes a

  • 0

I have been assigned wit the task to write a program that takes a sample raw YUV file and display it in a Cocoa OpenGL program.

I am an intern at my job and I have little or no clue how to start. I have been reading wikipedia & articles on YUV, but I couldn’t find any good source code on how to open a raw YUV file, extract the data and convert it into RGB and display it in the view window.

Essentially, I need help with the following aspects of the task
-how to extract the YUV data from the sample YUV file
-how to convert the YUV data into RGB color space
-how to display the RGB color space in OpenGL. (This one I think I can figure out with time, but I really need help with the first two points)

please either tell me the classes to use, or point me to places where i can learn about YUV graphic/video display

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T00:06:43+00:00Added an answer on May 12, 2026 at 12:06 am

    This answer is not correct, see the other answers and comments. Original answer left below for posterity.


    You can’t display it directly. You’ll need to convert it to an RGB texture. As you may have gathered from Wikipedia, there are a bunch of variations on the YUV color space. Make sure you’re using the right one.

    For each pixel, the conversion from YUV to RGB is a straightforward linear transformation. You just do the same thing to each pixel independently.

    Once you’ve converted the image to RGB, you can display it by creating a texture. You need to call glGenTextures() to allocate a texture handle, glBindTexture() to bind the texture to the render context, and glTexImage2D() to upload the texture data to the GPU. To render it, you again call glBindTexture(), followed by the rendering of a quad with texture coordinates set up properly.

    // parameters: image:  pointer to raw YUV input data
    //             width:  image width (must be a power of 2)
    //             height: image height (must be a power of 2)
    // returns: a handle to the resulting RGB texture
    GLuint makeTextureFromYUV(const float *image, int width, int height)
    {
        float *rgbImage = (float *)malloc(width * height * 3 * sizeof(float));  // check for NULL
        float *rgbImagePtr = rgbImage;
    
        // convert from YUV to RGB (floats used here for simplicity; it's a little
        // trickier with 8-bit ints)
        int y, x;
        for(y = 0; y < height; y++)
        {
            for(x = 0; x < width; x++)
            {
                float Y = *image++;
                float U = *image++;
                float V = *image++;
                *rgbImagePtr++ = Y                + 1.13983f * V;  // R
                *rgbImagePtr++ = Y - 0.39465f * U - 0.58060f * V;  // G
                *rgbImagePtr++ = Y + 2.03211f * U;                 // B
            }
        }
    
        // create texture
        GLuint texture;
        glGenTextures(1, &texture);
    
        // bind texture to render context
        glBindTexture(GL_TEXTURE_2D, texture);
    
        // upload texture data
        glTexImage2D(GL_TEXTURE_2D, 0, 3, width, height, 0, GL_RGB, GL_FLOAT, rgbImage);
    
        // don't use mipmapping (since we're not creating any mipmaps); the default
        // minification filter uses mipmapping.  Use linear filtering for minification
        // and magnification.
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    
        // free data (it's now been copied onto the GPU) and return texture handle
        free(rgbImage);
        return texture;
    }
    

    To render:

    glBindTexture(GL_TEXTURE_2D, texture);
    
    glBegin(GL_QUADS);
        glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.0f,  0.0f, 0.0f);
        glTexCoord2f(1.0f, 0.0f); glVertex3f(64.0f,  0.0f, 0.0f);
        glTexCoord2f(1.0f, 1.0f); glVertex3f(64.0f, 64.0f, 0.0f);
        glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, 64.0f, 0.0f);
    glEnd();
    

    And don’t forget to call glEnable(GL_TEXTURE_2D) at some point during initialization, and call glDeleteTextures(1, &texture) during shutdown.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 123k
  • Answers 123k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer No. Captchas are only valid captchas if they can automatically… May 12, 2026 at 1:08 am
  • Editorial Team
    Editorial Team added an answer And I found the answer. In your parent activity, before… May 12, 2026 at 1:08 am
  • Editorial Team
    Editorial Team added an answer Your problem is that when you do: <xsl:call-template name="kreator" />… May 12, 2026 at 1:08 am

Related Questions

I have been assigned a project to develop a set of classes that act
I have been assigned to add a forum into an in-house CMS we have
For my assignment I have been assigned the task of creating a DTD for
For a university assignment I have been assigned I have a Prize object which
Part of a new product I have been assigned to work on involves server-side

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.