Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. What this function does?

What this function does?

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Django_Untaken
    wrote on last edited by
    #1

    Hello Audio/Video Gurus. I don't seem to understand what following does. Here is the function.

    void TransformImage_YUY2( BYTE* pDest,
    LONG lDestStride,
    const BYTE* pSrc,
    LONG lSrcStride,
    DWORD dwWidthInPixels,
    DWORD dwHeightInPixels)
    {
    for (DWORD y = 0; y < dwHeightInPixels; y++)
    {
    RGBQUAD *pDestPel = (RGBQUAD*)pDest;
    WORD *pSrcPel = (WORD*)pSrc;

        for (DWORD x = 0; x < dwWidthInPixels; x += 2)
        {
            // Byte order is U0 Y0 V0 Y1
    
            int y0 = (int)LOBYTE(pSrcPel\[x\]); 
            int u0 = (int)HIBYTE(pSrcPel\[x\]);
            int y1 = (int)LOBYTE(pSrcPel\[x + 1\]);
            int v0 = (int)HIBYTE(pSrcPel\[x + 1\]);
    
            pDestPel\[x\] = ConvertYCrCbToRGB(y0, v0, u0);
            pDestPel\[x + 1\] = ConvertYCrCbToRGB(y1, v0, u0);
        }
    
        pSrc += lSrcStride;
        pDest += lDestStride;
    }
    

    }

    So, whether above function converts YUV to RGB32 or vice versa. Thanks for your input.

    J 1 Reply Last reply
    0
    • D Django_Untaken

      Hello Audio/Video Gurus. I don't seem to understand what following does. Here is the function.

      void TransformImage_YUY2( BYTE* pDest,
      LONG lDestStride,
      const BYTE* pSrc,
      LONG lSrcStride,
      DWORD dwWidthInPixels,
      DWORD dwHeightInPixels)
      {
      for (DWORD y = 0; y < dwHeightInPixels; y++)
      {
      RGBQUAD *pDestPel = (RGBQUAD*)pDest;
      WORD *pSrcPel = (WORD*)pSrc;

          for (DWORD x = 0; x < dwWidthInPixels; x += 2)
          {
              // Byte order is U0 Y0 V0 Y1
      
              int y0 = (int)LOBYTE(pSrcPel\[x\]); 
              int u0 = (int)HIBYTE(pSrcPel\[x\]);
              int y1 = (int)LOBYTE(pSrcPel\[x + 1\]);
              int v0 = (int)HIBYTE(pSrcPel\[x + 1\]);
      
              pDestPel\[x\] = ConvertYCrCbToRGB(y0, v0, u0);
              pDestPel\[x + 1\] = ConvertYCrCbToRGB(y1, v0, u0);
          }
      
          pSrc += lSrcStride;
          pDest += lDestStride;
      }
      

      }

      So, whether above function converts YUV to RGB32 or vice versa. Thanks for your input.

      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      You may ask the author. But the meaningful function name ConvertYCrCbToRGB should answer your question. This link may be also helpful: http://www.equasys.de/colorconversion.html[^].

      E 1 Reply Last reply
      0
      • J Jochen Arndt

        You may ask the author. But the meaningful function name ConvertYCrCbToRGB should answer your question. This link may be also helpful: http://www.equasys.de/colorconversion.html[^].

        E Offline
        E Offline
        econy
        wrote on last edited by
        #3

        InvalidateRect(rect,FALSE);
        DrawText(hDC,dtcMsgStr,-1,rect,DT_WORDBREAK|DT_LEFT);

        I tried the above way, same phenomenon

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups