FFmpegFB.h revision dbad8d5cc357812b98ebba09d541c4ba21edef3b
/** @file
*
* VBox Remote Desktop Protocol.
* FFmpeg framebuffer interface.
*/
/*
* Copyright (C) 2006-2007 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifndef _H_FFMPEGFB
#define _H_FFMPEGFB
#include <iprt/initterm.h>
#include <iprt/critsect.h>
#ifdef DEBUG
# define VBOX_DEBUG_FF DEBUG
# include <avcodec.h>
# include <avformat.h>
# define DEBUG VBOX_DEBUG_FF
#else /* DEBUG not defined */
# include <avcodec.h>
# include <avformat.h>
#endif /* DEBUG not defined */
{
#ifndef VBOX_WITH_XPCOM
{
return ::InterlockedIncrement (&refcnt);
}
{
if (cnt == 0)
return cnt;
}
#endif
// public methods only for internal purposes
/** true if url_fopen actually succeeded */
bool mfUrlOpen;
/** Guest framebuffer width */
/** Guest framebuffer height */
/** Bit rate used for encoding */
/** Guest framebuffer pixel format */
/** Guest framebuffer color depth */
/** Name of the file we will write to */
/** Guest framebuffer line length */
/** MPEG frame framebuffer width */
/** MPEG frame framebuffer height */
/** The size of one YUV frame */
/** If we can't use the video RAM directly, we allocate our own
* buffer */
/** The address of the buffer - can be either mRGBBuffer or the
* guests VRAM (HC address) if we can handle that directly */
/** An intermediary RGB buffer with the same dimensions */
/** Frame buffer translated into YUV420 for the mpeg codec */
/** Temporary buffer into which the codec writes frames to be
* written into the file */
/** File where we store the mpeg stream */
/** time at which the last "real" frame was created */
/** Pointer to ffmpeg's format information context */
/** ffmpeg context containing information about the stream */
/** Information for ffmpeg describing the current frame */
/** ffmpeg pixel format of guest framebuffer */
int mFFMPEGPixelFormat;
/** Since we are building without exception support, we use this
to signal allocation failure in the constructor */
bool mOutOfMemory;
/** A hack: ffmpeg mpeg2 only writes a frame if something has
changed. So we flip the low luminance bit of the first
pixel every frame. */
bool mToggle;
#ifndef VBOX_WITH_XPCOM
long refcnt;
#endif
};
/**
* Iterator class for running through an BGRA32 image buffer and converting
* it to RGB.
*/
{
enum { PIX_SIZE = 4 };
{
mPos = 0;
}
/**
* Convert the next pixel to RGB.
* @returns true on success, false if we have reached the end of the buffer
* @param aRed where to store the red value
* @param aGreen where to store the green value
* @param aBlue where to store the blue value
*/
{
bool rc = false;
{
rc = true;
}
return rc;
}
/**
* Skip forward by a certain number of pixels
* @param aPixels how many pixels to skip
*/
{
}
/** Size of the picture buffer */
unsigned mSize;
/** Current position in the picture buffer */
unsigned mPos;
/** Address of the picture buffer */
};
/**
* Iterator class for running through an BGR24 image buffer and converting
* it to RGB.
*/
{
enum { PIX_SIZE = 3 };
{
mPos = 0;
}
/**
* Convert the next pixel to RGB.
* @returns true on success, false if we have reached the end of the buffer
* @param aRed where to store the red value
* @param aGreen where to store the green value
* @param aBlue where to store the blue value
*/
{
bool rc = false;
{
rc = true;
}
return rc;
}
/**
* Skip forward by a certain number of pixels
* @param aPixels how many pixels to skip
*/
{
}
/** Size of the picture buffer */
unsigned mSize;
/** Current position in the picture buffer */
unsigned mPos;
/** Address of the picture buffer */
};
/**
* Iterator class for running through an BGR565 image buffer and converting
* it to RGB.
*/
{
enum { PIX_SIZE = 2 };
{
mPos = 0;
}
/**
* Convert the next pixel to RGB.
* @returns true on success, false if we have reached the end of the buffer
* @param aRed where to store the red value
* @param aGreen where to store the green value
* @param aBlue where to store the blue value
*/
{
bool rc = false;
{
rc = true;
}
return rc;
}
/**
* Skip forward by a certain number of pixels
* @param aPixels how many pixels to skip
*/
{
}
/** Size of the picture buffer */
unsigned mSize;
/** Current position in the picture buffer */
unsigned mPos;
/** Address of the picture buffer */
};
/**
* Convert an image to YUV420p format
* @returns true on success, false on failure
* @param aWidth width of image
* @param aHeight height of image
* @param aDestBuf an allocated memory buffer large enough to hold the
* destination image (i.e. width * height * 12bits)
* @param aSrcBuf the source image as an array of bytes
*/
{
bool rc = true;
unsigned offY = 0;
{
{
if (rc)
{
}
if (rc)
{
}
if (rc)
{
}
if (rc)
{
offY += 2;
++offU;
++offV;
}
}
if (rc)
{
}
}
return rc;
}
/**
* Convert an image to RGB24 format
* @returns true on success, false on failure
* @param aWidth width of image
* @param aHeight height of image
* @param aDestBuf an allocated memory buffer large enough to hold the
* destination image (i.e. width * height * 12bits)
* @param aSrcBuf the source image as an array of bytes
*/
{
enum { PIX_SIZE = 3 };
bool rc = true;
{
if (rc)
{
}
}
return rc;
}
#endif /* !_H_FFMPEGFB */