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 6721105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:17:25+00:00 2026-05-26T09:17:25+00:00

I know how to code a shader that converts planar data (YUV420 image) to

  • 0

I know how to code a shader that converts planar data (YUV420 image) to packed one (RGB image) using fragment shader, yet how do I code the RGB to YUV420.
I do not need the YUV420 image for rendering but to pass it to the h264 compression code.

  • 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-26T09:17:26+00:00Added an answer on May 26, 2026 at 9:17 am

    From http://www.fourcc.org/fccyvrgb.php:

    RGB to YUV Conversion

    Y = (0.257 * R) + (0.504 * G) + (0.098 * B) + 16

    Cr = V = (0.439 * R) – (0.368 * G) – (0.071 * B) + 128

    Cb = U = -(0.148 * R) – (0.291 * G) + (0.439 * B) + 128

    In a OpenGL shader those constant offsets at the end need to be multiplied by 1/256. Also if you look closely this is a vector-matrix multiplication. You can express this by

    mat4 RGBtoYUV(0.257,  0.439, -0.148, 0.0,
                  0.504, -0.368, -0.291, 0.0,
                  0.098, -0.071,  0.439, 0.0,
                  0.0625, 0.500,  0.500, 1.0 );
    
    YUV = RGBtoYUV * RGB;
    

    Some other formulas are given at http://en.wikipedia.org/wiki/YUV

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

Sidebar

Related Questions

In code: //I know that to get this effect (being able to use it
I know that c++ code should be compiled and linked by g++, not gcc.
I know that GUI code in Java Swing must be put inside SwingUtilities.invokeAndWait or
Does anyone know of any code or tools that can strip literal values out
I declare my GLSL ES shader program within a HTML file, using this code:
I am drawing one object using multi-texturing. That comes fine but when I draw
I have the following code in the Fragment Shader: precision lowp float; varying vec2
I know about code-behind files, but what is the best real-world way of Designers
I know the code is missing (Someone will give negative numbers). But I only
Is there a way to know when code is being called from running a

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.