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

  • Home
  • SEARCH
  • 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 6565271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:04:25+00:00 2026-05-25T14:04:25+00:00

I have a buffer of UYVY data from a camera and i am using

  • 0

I have a buffer of UYVY data from a camera and i am using the GSSF Directshow.net filter to push the buffer through a graph.

The Graph at the moment is

GSSF -> YUV Transform -> AVI Splitter -> Video Renderer

The graph correctly calculates the color and is displaying it correctly but theres bars in the image that shouldn’t be there and i am not sure where they are coming from. It hurts my eyes to stare at the image.

enter image description here

This function takes the UYVY buffer (mainbyte) and copies it to an array of integers

        unsafe public void ImageFromPixels__()
    {
        byte[] x = mainbyte;
        long fff = 720 * 1280;
        mainptr = new IntPtr(fff);
        for (int p = 0; p < 720 * 1280; p++)
        {
            U = (x[p * 4 + 0]);

            Y = (x[p * 4 + 1]);
            V = (x[p * 4 + 2]);
            Y2 = (x[p * 4 + 3]);

           // int one = V << 16 | Y << 8 | U;
           // int two = V << 16 | Y2 << 8 | U;
            int one = Y2 << 24 | V << 16 | Y << 8 | U;
           // mainint[p * 2 + 0] = one;
           // mainint[p * 2 + 1] = two;
            mainint[p] = one;

        }

        m_FPS = UNIT / 20;
        m_b = 211;
        m_g = 197;
    }

This function takes that same array of integers and packs it into the GSSF stream pointer

        override unsafe public int GetImage(int iFrameNumber, IntPtr ip, int iSize, out int iRead)
    {
        int hr = 0;

        if (iFrameNumber>-1)
        {
            if (iFrameNumber < MAXFRAMES)
            {
                ImageFromPixels_(20, mainbyte);

                m_g += 3;
                m_b += 7;
                int* bp = (int*)ip.ToPointer();
                Random k = new Random();

                StreamReader s = new StreamReader("jpegFile.txt");
                for (int f = 0; f < HEIGHT; f++)
                {
                    for (int x = 0; x < (WIDTH); x += 1)
                    {
                        *(bp + (f * WIDTH) + x) = mainint[f * 1280 + x];
                    }
                }
            }
            else
            {
                hr = 1; // End of stream
            }
        }

        iRead = iSize;

        return hr;
    }

This sets up the bitmap compression for the output pin of the GSSF
I think i may be doing something wrong here but it looks correct.

        override public void SetMediaType(IGenericSampleConfig psc)
    {
        BitmapInfoHeader bmi = new BitmapInfoHeader();

        // Build a BitmapInfo struct using the parms from the file
        bmi.Size = Marshal.SizeOf(typeof(BitmapInfoHeader));
        bmi.Width = WIDTH;
        bmi.Height = HEIGHT * -1;
        bmi.Planes = 1;
        bmi.BitCount = BPP;
        bmi.Compression = 0x59565955; //UYVY
        bmi.ImageSize = (bmi.BitCount / 8) * bmi.Width * bmi.Height;
        bmi.XPelsPerMeter = 0;
        bmi.YPelsPerMeter = 0;
        bmi.ClrUsed = 0;
        bmi.ClrImportant = 0;

        int hr = psc.SetMediaTypeFromBitmap(bmi, m_FPS);
        DsError.ThrowExceptionForHR(hr);
    }

UPDATE
changed it abit

        override unsafe public int GetImage(int iFrameNumber, IntPtr ip, int iSize, out int iRead)
    {
        int hr = 0;

        if (iFrameNumber>-1)
        {
            if (iFrameNumber < MAXFRAMES)
            {
                ImageFromPixels_(20, mainbyte);

                m_g += 3;
                m_b += 7;
                int* bp = (int*)ip.ToPointer();
                Random k = new Random();
                StreamReader s = new StreamReader("jpegFile.txt");
                for (int f = 0; f < 720; f++)
                {
                    for (int x = 0; x < (1280); x += 1)
                    {
                        *(bp + (f * 1280) + x) = mainint[f * 1280 + x];
                    }
                }
            }
            else
            {
                hr = 1; // End of stream
            }
        }

//
override public void SetMediaType(IGenericSampleConfig psc)
{
BitmapInfoHeader bmi = new BitmapInfoHeader();

        // Build a BitmapInfo struct using the parms from the file
        bmi.Size = Marshal.SizeOf(typeof(BitmapInfoHeader));
        bmi.Width = WIDTH;
        bmi.Height = HEIGHT * -1;
        bmi.Planes = 1;
        bmi.BitCount = BPP;
        bmi.Compression = 0x59565955;
        bmi.ImageSize = (bmi.BitCount / 8) * bmi.Width * bmi.Height;
        bmi.XPelsPerMeter = 0;
        bmi.YPelsPerMeter = 0;
        bmi.ClrUsed = 0;
        bmi.ClrImportant = 0;

        int hr = psc.SetMediaTypeFromBitmap(bmi, m_FPS);
        DsError.ThrowExceptionForHR(hr);
    }

//

        unsafe public void ImageFromPixels_(long FPS, byte[] x)
    {

        long fff = 720 * 1280 * 3;
        mainptr = new IntPtr(fff);
        for (int p = 0; p < 720 * 640; p++)
        {
            U = (x[ p * 4 + 0]);

            Y = (x[p * 4 + 1]);
            V = (x[p * 4 + 2]);
            Y2 = (x[p * 4 + 3]);

            int one = Y2 << 24 | V << 16 | Y << 8 | U;
            //int one = V << 16 | Y << 8 | U;
            //int two = V << 16 | Y2 << 8 | U;
            //mainint[p * 2 + 0] = one;
            //mainint[p * 2 + 1] = two;
            mainint[p] = one;

        }

        m_FPS = UNIT / FPS;
        m_b = 211;
        m_g = 197;
    }

enter image description here

if i change the other numbers within GetImage to alter the height of the video, or if i chnge it inside of ImagePixel then i just get black screens 😐

  • 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-25T14:04:26+00:00Added an answer on May 25, 2026 at 2:04 pm

    Pointer math sucks. Changed my code from

    for (int f = 0; f < 720; f++)
    {
        for (int x = 0; x < (1280); x += 1)
        {
            *(bp + (f * 1280) + x) = mainbyte[f * 1280 + x];
        }
    }
    

    to

    Marshal.Copy(mainbyte, 0, ip, 1280*720);
    

    and changed BPP from 32 to 16 and it now works without a hitch.

    <_<

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

Sidebar

Related Questions

So.. I have a buffer with MP3 data (If I would save this buffer
I have a char array buffer that I am using to store characters that
I have a buffer (uint8[] of BGR pixel data) in C holding a video
I have this buffer which I use for store some different types of data:
I have a buffer which I receive through a serial port. When I receive
If I have a buffer which contains the data of a file, how can
I have a requirement wherein I have to buffer a lot of data (in
I have a buffer that is text read from a file. I loop over
I have Protocol Buffer for logging data. message Message { required double val1 =
I'm having an issue reading from a java input stream. I have a buffer

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.