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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:19:06+00:00 2026-06-04T17:19:06+00:00

I am trying to fill sample data for a AVFrame initialized with RGB24 format.

  • 0

I am trying to fill sample data for a AVFrame initialized with RGB24 format.
I use following code snippet to populate RGB data.
But in the encoded video,I can only see grayscale strip covering only 1/3 of the videoframe.
This code snippet suppose to fill only Red color.
Any tips what Im doing wrong here ?

AVFrame *targetFrame=.....
int height=imageHeight();
int width=imageWidth();


  for(y=0;y<encoder.getVideoParams().height ;y++){   
       for(x=0;x< encoder.getVideoParams().width;x++){


   targetFrame->data[0][(y* width)+x]=(x%255); //R  
   targetFrame->data[0][(y* width)+x+1]=0;     //G
   targetFrame->data[0][(y* width)+x+2]=0;     //B


  }
   }
  • 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-06-04T17:19:07+00:00Added an answer on June 4, 2026 at 5:19 pm

    If you’re using RGB24, you need to scale the coordinates before indexing into the data buffer. Here’s a version of your inner loop that’ll do it properly:

    int offset = 3 * (x + y * width);
    targetFrame->data[0][offset + 0] = x % 255; // R
    targetFrame->data[0][offset + 1] = 0; // G
    targetFrame->data[0][offset + 2] = 0; // B
    

    And here’s a simpler approach:

    uint8_t *p = targetFrame->data[0];
    for(y = 0; y < encoder.getVideoParams().height; y++) {  
        for(x = 0; x < encoder.getVideoParams().width; x++) {
            *p++ = x % 255; // R
            *p++ = 0; // G
            *p++ = 0; // B
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to fill object[] with List<string> but I cannot figure out how
I am trying to fill a table with JSON data. When I run the
I am trying to fill up my matrix with zeros. Unfortunatelly, in the following
I'm trying to fill some data from an xml feed we made into my
I am trying to fill gridpanel to get data from database through LINQ in
I'm trying to fill a torus texture of wood, but leaves only one color:
Very simple problem...but weird results. Im just trying to fill a drop down list
I'm trying to write some simple C# code that will select some data from
Greetings great SO comrades; I'm trying to use this code to make changes to
i m trying to run the bluetooth chat sample from the developers site but

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.