29 #ifndef PTLIB_CONVERT_H
30 #define PTLIB_CONVERT_H
205 const BYTE * srcFrameBuffer,
206 BYTE * dstFrameBuffer,
207 PINDEX * bytesReturned = NULL
228 PINDEX * bytesReturned = NULL,
229 PBoolean noIntermediateFrame =
false
242 const PString & srcColourFormat,
243 const PString & destColourFormat,
270 PVideoFrameInfo::ResizeMode mode
271 ) {
if (mode < PVideoFrameInfo::eMaxResizeMode)
m_resizeMode = mode; }
280 unsigned r,
unsigned g,
unsigned b,
281 BYTE & y, BYTE & u, BYTE & v
287 unsigned y,
unsigned u,
unsigned v,
288 BYTE & r, BYTE & g, BYTE & b
295 unsigned srcX,
unsigned srcY,
unsigned srcWidth,
unsigned srcHeight,
296 unsigned srcFrameWidth,
unsigned srcFrameHeight,
const BYTE * srcYUV,
297 unsigned dstX,
unsigned dstY,
unsigned dstWidth,
unsigned dstHeight,
298 unsigned dstFrameWidth,
unsigned dstFrameHeight, BYTE * dstYUV,
299 PVideoFrameInfo::ResizeMode resizeMode = PVideoFrameInfo::eScale,
300 bool verticalFlip =
false, std::ostream * error = NULL
310 int angle,
unsigned width,
unsigned height, BYTE * srcYUV, BYTE * dstYUV = NULL
316 unsigned x,
unsigned y,
unsigned width,
unsigned height,
317 unsigned frameWidth,
unsigned frameHeight, BYTE * yuv,
318 unsigned r_or_y,
unsigned g_or_u,
unsigned b_or_v,
348 #define PCOLOUR_CONVERTER2(cls,ancestor,srcFmt,dstFmt) \
349 class cls : public ancestor { \
351 cls() : ancestor(PColourPair(srcFmt, dstFmt)) { } \
352 virtual PBoolean Convert(const BYTE *, BYTE *, PINDEX * = NULL); \
354 PFACTORY_CREATE(PColourConverterFactory, cls, PColourPair(srcFmt, dstFmt)); \
355 PBoolean cls::Convert(const BYTE *srcFrameBuffer, BYTE *dstFrameBuffer, PINDEX * bytesReturned) \
363 #define PCOLOUR_CONVERTER(cls,src,dst) \
364 PCOLOUR_CONVERTER2(cls,PColourConverter,src,dst)
393 PVideoFrameInfo::ResizeMode resizeMode = PVideoFrameInfo::eScaleKeepAspect,
417 const BYTE * srcFrameBuffer,
418 BYTE * dstFrameBuffer,
419 PINDEX * bytesReturned = NULL
434 #endif // P_JPEG_DECODER
438 #endif // PTLIB_CONVERT_H
virtual void GetSrcFrameInfo(PVideoFrameInfo &info)
Get the source frame info to be used.
P_REMOVE_VIRTUAL(PBoolean, Convert(const BYTE *, BYTE *, unsigned, PINDEX *), false)
static void RGBtoYUV(unsigned r, unsigned g, unsigned b, BYTE &y, BYTE &u, BYTE &v)
Convert RGB to YUV.
virtual void PrintOn(ostream &strm) const
Print description of converter.
virtual PBoolean SetDstFrameSize(unsigned width, unsigned height)
Set the destination frame size to be used.
This class represents a disk file.
Definition: file.h:57
PBYTEArray m_intermediateFrameStore
Definition: vconvert.h:335
virtual PBoolean SetFrameSize(unsigned width, unsigned height)
Set the frame size to be used.
virtual PBoolean SetSrcFrameSize(unsigned width, unsigned height)
Set the source frame size to be used.
virtual void GetDstFrameInfo(PVideoFrameInfo &info)
Get the destination frame info to be used.
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:2164
unsigned GetDstFrameHeight() const
Definition: vconvert.h:265
virtual PBoolean ConvertInPlace(BYTE *frameBuffer, PINDEX *bytesReturned=NULL, PBoolean noIntermediateFrame=false)
Convert from one colour format to another.
PVideoFrameInfo::ResizeMode m_resizeMode
Definition: vconvert.h:332
This class describes a full description for a file on the particular platform.
Definition: filepath.h:61
Comparison
Result of the comparison operation performed by the Compare() function.
Definition: object.h:2251
void SetSrcFrameBytes(PINDEX frameBytes)
Set the actual frame size in bytes for source frames.
Definition: vconvert.h:185
PColourConverter(const PColourPair &colours)
Create a new converter.
unsigned GetDstFrameWidth() const
Definition: vconvert.h:264
This class contains a pair of colour formats for conversion.
Definition: vconvert.h:47
PColourPair(const PString &src, const PString &dst)
Definition: vconvert.h:51
static const PString & YUV420P()
virtual PBoolean Convert(const BYTE *srcFrameBuffer, BYTE *dstFrameBuffer, PINDEX *bytesReturned=NULL)=0
Convert from one colour format to another.
unsigned m_dstFrameWidth
Definition: vconvert.h:328
PINDEX m_srcFrameBytes
Definition: vconvert.h:325
Comparison Compare(const PObject &other) const
Compare the two objects and return their relative rank.
unsigned GetSrcFrameWidth() const
Definition: vconvert.h:262
Array of unsigned characters.
Definition: array.h:605
static void YUVtoRGB(unsigned y, unsigned u, unsigned v, BYTE &r, BYTE &g, BYTE &b)
Convert YUV to RGB.
const PString & GetDstColourFormat() const
Get the destination colour format.
Definition: vconvert.h:64
PBoolean GetSrcFrameSize(unsigned &width, unsigned &height) const
Get the input frame size.
void SetResizeMode(PVideoFrameInfo::ResizeMode mode)
Set the resize mode to be used.
Definition: vconvert.h:269
unsigned GetSrcFrameHeight() const
Definition: vconvert.h:263
bool PBoolean
Definition: object.h:174
bool GetVFlipState() const
Get the video conversion vertical flip state.
Definition: vconvert.h:92
virtual PBoolean SetDstFrameInfo(const PVideoFrameInfo &info)
Set the destination frame info to be used.
const PString m_srcColourFormat
Definition: vconvert.h:67
The character string class.
Definition: pstring.h:108
static PColourConverter * Create(const PVideoFrameInfo &src, const PVideoFrameInfo &dst)
Create an instance of a colour conversion function.
PBoolean GetDstFrameSize(unsigned &width, unsigned &height) const
Get the output frame size.
unsigned m_dstFrameHeight
Definition: vconvert.h:329
Class for a factory to create concrete class instances without parameters during construction.
Definition: pfactory.h:396
This class defines a means to convert an image from one colour format to another. ...
Definition: vconvert.h:74
PINDEX GetMaxSrcFrameBytes() const
Get the maximum frame size in bytes for source frames.
Definition: vconvert.h:178
bool m_verticalFlip
Definition: vconvert.h:333
unsigned m_srcFrameWidth
Definition: vconvert.h:323
static bool CopyYUV420P(unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight, unsigned srcFrameWidth, unsigned srcFrameHeight, const BYTE *srcYUV, unsigned dstX, unsigned dstY, unsigned dstWidth, unsigned dstHeight, unsigned dstFrameWidth, unsigned dstFrameHeight, BYTE *dstYUV, PVideoFrameInfo::ResizeMode resizeMode=PVideoFrameInfo::eScale, bool verticalFlip=false, std::ostream *error=NULL)
Copy a section of the source frame to a section of the destination frame with scaling/cropping as req...
PINDEX m_dstFrameBytes
Definition: vconvert.h:330
unsigned m_srcFrameHeight
Definition: vconvert.h:324
const PString & GetSrcColourFormat() const
Get the source colour format.
Definition: vconvert.h:60
PFactory< PColourConverter, PColourPair > PColourConverterFactory
Definition: vconvert.h:340
PINDEX GetMaxDstFrameBytes() const
Get the maximum frame size in bytes for destination frames.
Definition: vconvert.h:192
Ultimate parent class for all objects in the class library.
Definition: object.h:2204
const PString m_dstColourFormat
Definition: vconvert.h:68
PVideoFrameInfo::ResizeMode GetResizeMode() const
Get the resize mode to be used.
Definition: vconvert.h:275
void SetVFlipState(bool vFlipState)
Set the video conversion vertical flip state.
Definition: vconvert.h:97
virtual PBoolean SetSrcFrameInfo(const PVideoFrameInfo &info)
Set the source frame info to be used.
static bool RotateYUV420P(int angle, unsigned width, unsigned height, BYTE *srcYUV, BYTE *dstYUV=NULL)
Rotate the video buffer image.
static bool FillYUV420P(unsigned x, unsigned y, unsigned width, unsigned height, unsigned frameWidth, unsigned frameHeight, BYTE *yuv, unsigned r_or_y, unsigned g_or_u, unsigned b_or_v, bool rgb=true)
Fill a rectangle of the video buffer with the specified colour.