VirtualBox

Ignore:
Timestamp:
Jun 24, 2024 5:43:00 PM (8 months ago)
Author:
vboxsync
Message:

Video Recording: Big revamp to improve overall performance. We now don't rely on the periodic display refresh callback anymore to render the entire framebuffer but now rely on delta updates ("dirty rectangles"). Also, we now only encode new frames when an area has changed. This also needed cursor position + change change notifications, as we render the cursor on the host side if mouse integration is enabled (requires 7.1 Guest Additions as of now). Optimized the BGRA32->YUV IV420 color space conversion as well as the overall amount of pixel data shuffled forth and back. Added a new testcase for the cropping/centering code. bugref:10650

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/RecordingUtils.h

    r98103 r105006  
    3535
    3636
    37 /**
    38  * Iterator class for running through a BGRA32 image buffer and converting
    39  * it to RGB.
    40  */
    41 class ColorConvBGRA32Iter
    42 {
    43 private:
    44     enum { PIX_SIZE = 4 };
    45 public:
    46     ColorConvBGRA32Iter(unsigned aWidth, unsigned aHeight, uint8_t *aBuf)
    47     {
    48         mPos = 0;
    49         mSize = aWidth * aHeight * PIX_SIZE;
    50         mBuf = aBuf;
    51     }
    52 
    53     /**
    54      * Convert the next pixel to RGB.
    55      *
    56      * @returns true on success, false if we have reached the end of the buffer
    57      * @param   aRed            where to store the red value.
    58      * @param   aGreen          where to store the green value.
    59      * @param   aBlue           where to store the blue value.
    60      */
    61     bool getRGB(unsigned *aRed, unsigned *aGreen, unsigned *aBlue)
    62     {
    63         bool rc = false;
    64         if (mPos + PIX_SIZE <= mSize)
    65         {
    66             *aRed   = mBuf[mPos + 2];
    67             *aGreen = mBuf[mPos + 1];
    68             *aBlue  = mBuf[mPos    ];
    69             mPos += PIX_SIZE;
    70             rc = true;
    71         }
    72         return rc;
    73     }
    74 
    75     /**
    76      * Skip forward by a certain number of pixels.
    77      *
    78      * @param aPixels           How many pixels to skip.
    79      */
    80     void skip(unsigned aPixels)
    81     {
    82         mPos += PIX_SIZE * aPixels;
    83     }
    84 private:
    85     /** Size of the picture buffer. */
    86     unsigned mSize;
    87     /** Current position in the picture buffer. */
    88     unsigned mPos;
    89     /** Address of the picture buffer. */
    90     uint8_t *mBuf;
    91 };
    92 
    93 /**
    94  * Iterator class for running through an BGR24 image buffer and converting
    95  * it to RGB.
    96  */
    97 class ColorConvBGR24Iter
    98 {
    99 private:
    100     enum { PIX_SIZE = 3 };
    101 public:
    102     ColorConvBGR24Iter(unsigned aWidth, unsigned aHeight, uint8_t *aBuf)
    103     {
    104         mPos = 0;
    105         mSize = aWidth * aHeight * PIX_SIZE;
    106         mBuf = aBuf;
    107     }
    108 
    109     /**
    110      * Convert the next pixel to RGB.
    111      *
    112      * @returns true on success, false if we have reached the end of the buffer.
    113      * @param   aRed            where to store the red value.
    114      * @param   aGreen          where to store the green value.
    115      * @param   aBlue           where to store the blue value.
    116      */
    117     bool getRGB(unsigned *aRed, unsigned *aGreen, unsigned *aBlue)
    118     {
    119         bool rc = false;
    120         if (mPos + PIX_SIZE <= mSize)
    121         {
    122             *aRed   = mBuf[mPos + 2];
    123             *aGreen = mBuf[mPos + 1];
    124             *aBlue  = mBuf[mPos    ];
    125             mPos += PIX_SIZE;
    126             rc = true;
    127         }
    128         return rc;
    129     }
    130 
    131     /**
    132      * Skip forward by a certain number of pixels.
    133      *
    134      * @param aPixels           How many pixels to skip.
    135      */
    136     void skip(unsigned aPixels)
    137     {
    138         mPos += PIX_SIZE * aPixels;
    139     }
    140 private:
    141     /** Size of the picture buffer. */
    142     unsigned mSize;
    143     /** Current position in the picture buffer. */
    144     unsigned mPos;
    145     /** Address of the picture buffer. */
    146     uint8_t *mBuf;
    147 };
    148 
    149 /**
    150  * Iterator class for running through an BGR565 image buffer and converting
    151  * it to RGB.
    152  */
    153 class ColorConvBGR565Iter
    154 {
    155 private:
    156     enum { PIX_SIZE = 2 };
    157 public:
    158     ColorConvBGR565Iter(unsigned aWidth, unsigned aHeight, uint8_t *aBuf)
    159     {
    160         mPos = 0;
    161         mSize = aWidth * aHeight * PIX_SIZE;
    162         mBuf = aBuf;
    163     }
    164 
    165     /**
    166      * Convert the next pixel to RGB.
    167      *
    168      * @returns true on success, false if we have reached the end of the buffer.
    169      * @param   aRed            Where to store the red value.
    170      * @param   aGreen          where to store the green value.
    171      * @param   aBlue           where to store the blue value.
    172      */
    173     bool getRGB(unsigned *aRed, unsigned *aGreen, unsigned *aBlue)
    174     {
    175         bool rc = false;
    176         if (mPos + PIX_SIZE <= mSize)
    177         {
    178             unsigned uFull =  (((unsigned) mBuf[mPos + 1]) << 8)
    179                              | ((unsigned) mBuf[mPos]);
    180             *aRed   = (uFull >> 8) & ~7;
    181             *aGreen = (uFull >> 3) & ~3 & 0xff;
    182             *aBlue  = (uFull << 3) & ~7 & 0xff;
    183             mPos += PIX_SIZE;
    184             rc = true;
    185         }
    186         return rc;
    187     }
    188 
    189     /**
    190      * Skip forward by a certain number of pixels.
    191      *
    192      * @param aPixels           How many pixels to skip.
    193      */
    194     void skip(unsigned aPixels)
    195     {
    196         mPos += PIX_SIZE * aPixels;
    197     }
    198 private:
    199     /** Size of the picture buffer. */
    200     unsigned mSize;
    201     /** Current position in the picture buffer. */
    202     unsigned mPos;
    203     /** Address of the picture buffer. */
    204     uint8_t *mBuf;
    205 };
    206 
    207 int RecordingUtilsRGBToYUV(RECORDINGPIXELFMT enmPixelFormat,
    208                            uint8_t *paDst, uint32_t uDstWidth, uint32_t uDstHeight,
    209                            uint8_t *paSrc, uint32_t uSrcWidth, uint32_t uSrcHeight);
     37void RecordingUtilsConvBGRA32ToYUVI420(uint8_t *paDst, uint32_t uDstWidth, uint32_t uDstHeight,
     38                                       uint8_t *paSrc, uint32_t uSrcWidth, uint32_t uSrcHeight);
     39void RecordingUtilsConvBGRA32ToYUVI420Ex(uint8_t *paDst, uint32_t dx, uint32_t dy, uint32_t uDstWidth, uint32_t uDstHeight,
     40                                         uint8_t *paSrc, uint32_t sx, uint32_t sy, uint32_t uSrcWidth, uint32_t uSrcHeight, uint32_t uSrcStride, uint8_t uBPP);
     41int RecordingUtilsCoordsCropCenter(PRECORDINGCODECPARMS pCodecParms, int32_t *sx, int32_t *sy, int32_t *sw, int32_t *sh, int32_t *dx, int32_t *dy);
    21042
    21143#ifdef DEBUG
    212 int RecordingUtilsDbgDumpFrameEx(const uint8_t *pu8RGBBuf, size_t cbRGBBuf, const char *pszPath, const char *pszPrefx, uint16_t uWidth, uint32_t uHeight, uint8_t uBPP);
    213 int RecordingUtilsDbgDumpFrame(const PRECORDINGFRAME pFrame);
     44int RecordingUtilsDbgDumpImageData(const uint8_t *pu8RGBBuf, size_t cbRGBBuf, const char *pszPath, const char *pszWhat, uint32_t uWidth, uint32_t uHeight, uint32_t uBytesPerLine, uint8_t uBPP);
     45int RecordingUtilsDbgDumpVideoFrameEx(const PRECORDINGVIDEOFRAME pFrame, const char *pszPath, const char *pszWhat);
     46int RecordingUtilsDbgDumpVideoFrame(const PRECORDINGVIDEOFRAME pFrame, const char *pszWhat);
    21447#endif
    21548
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette