33 #ifndef PTLIB_CONVERT_H
34 #define PTLIB_CONVERT_H
42 #include <ptbuildopts.h>
61 const PString & srcColourFormat,
62 const PString & destColourFormat
218 const BYTE * srcFrameBuffer,
219 BYTE * dstFrameBuffer,
220 PINDEX * bytesReturned = NULL
224 const BYTE * srcFrameBuffer,
225 BYTE * dstFrameBuffer,
227 PINDEX * bytesReturned = NULL
248 PINDEX * bytesReturned = NULL,
249 PBoolean noIntermediateFrame =
false
262 const PString & srcColourFormat,
263 const PString & destColourFormat,
300 unsigned r,
unsigned g,
unsigned b,
301 unsigned & y,
unsigned & u,
unsigned & v
304 unsigned r,
unsigned g,
unsigned b,
305 BYTE & y, BYTE & u, BYTE & v
312 unsigned srcX,
unsigned srcY,
unsigned srcWidth,
unsigned srcHeight,
314 unsigned dstX,
unsigned dstY,
unsigned dstWidth,
unsigned dstHeight,
320 unsigned x,
unsigned y,
int width,
int height,
321 unsigned frameWidth,
unsigned frameHeight, BYTE * yuv,
322 unsigned r,
unsigned g,
unsigned b
362 #define PCOLOUR_CONVERTER2(cls,ancestor,srcFmt,dstFmt) \
363 class cls : public ancestor { \
365 cls(const PVideoFrameInfo & src, const PVideoFrameInfo & dst) \
366 : ancestor(src, dst) { } \
367 virtual PBoolean Convert(const BYTE *, BYTE *, PINDEX * = NULL); \
368 virtual PBoolean Convert(const BYTE *, BYTE *, unsigned int , PINDEX * = NULL); \
370 static class cls##_Registration : public PColourConverterRegistration { \
371 public: cls##_Registration() \
372 : PColourConverterRegistration(srcFmt,dstFmt) { } \
373 protected: virtual PColourConverter * Create(const PVideoFrameInfo & src, const PVideoFrameInfo & dst) const; \
374 } p_##cls##_registration_instance; \
375 PColourConverter * cls##_Registration::Create(const PVideoFrameInfo & src, const PVideoFrameInfo & dst) const \
376 { return new cls(src, dst); } \
377 PBoolean cls::Convert(const BYTE *srcFrameBuffer, BYTE *dstFrameBuffer, unsigned int p_srcFrameBytes, PINDEX * bytesReturned) \
378 { srcFrameBytes = p_srcFrameBytes;return Convert(srcFrameBuffer, dstFrameBuffer, bytesReturned); } \
379 PBoolean cls::Convert(const BYTE *srcFrameBuffer, BYTE *dstFrameBuffer, PINDEX * bytesReturned)
387 #define PCOLOUR_CONVERTER(cls,src,dst) \
388 PCOLOUR_CONVERTER2(cls,PColourConverter,src,dst)
403 virtual PBoolean Convert(
const BYTE *, BYTE *,
unsigned int , PINDEX * = NULL);
427 #define PSYNONYM_COLOUR_CONVERTER(from,to) \
428 static PSynonymColourRegistration p_##from##_##to##_registration_instance(#from,#to)
433 #endif // PTLIB_CONVERT_H
virtual void GetSrcFrameInfo(PVideoFrameInfo &info)
Get the source frame info to be used.
virtual PColourConverter * Create(const PVideoFrameInfo &src, const PVideoFrameInfo &dst) const
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.
ResizeMode
Definition: videoio.h:54
unsigned dstFrameWidth
Definition: vconvert.h:338
virtual PBoolean SetFrameSize(unsigned width, unsigned height)
Set the frame size to be used.
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)
Copy a section of the source frame to a section of the destination frame with scaling/cropping as req...
virtual PBoolean SetSrcFrameSize(unsigned width, unsigned height)
Set the source frame size to be used.
PColourConverterRegistration * link
Definition: vconvert.h:71
virtual void GetDstFrameInfo(PVideoFrameInfo &info)
Get the destination frame info to be used.
PINDEX GetMaxDstFrameBytes()
Get the maximum frame size in bytes for destination frames.
Definition: vconvert.h:205
const PString & GetDstColourFormat()
Get the destination colour format.
Definition: vconvert.h:191
unsigned GetDstFrameHeight() const
Definition: vconvert.h:285
static void RGBtoYUV(unsigned r, unsigned g, unsigned b, unsigned &y, unsigned &u, unsigned &v)
Convert RGB to YUV.
virtual PBoolean ConvertInPlace(BYTE *frameBuffer, PINDEX *bytesReturned=NULL, PBoolean noIntermediateFrame=false)
Convert from one colour format to another.
PSynonymColour(const PVideoFrameInfo &src, const PVideoFrameInfo &dst)
Definition: vconvert.h:398
PBoolean GetVFlipState()
Get the video conversion vertical flip state.
Definition: vconvert.h:104
PBYTEArray intermediateFrameStore
Definition: vconvert.h:346
This class is a variation of a string that ignores case.
Definition: pstring.h:1708
unsigned GetDstFrameWidth() const
Definition: vconvert.h:284
virtual PBoolean Convert(const BYTE *srcFrameBuffer, BYTE *dstFrameBuffer, PINDEX *bytesReturned=NULL)=0
Convert from one colour format to another.
PBoolean verticalFlip
Definition: vconvert.h:344
void Construct(const PVideoFrameInfo &src, const PVideoFrameInfo &dst)
unsigned srcFrameHeight
Definition: vconvert.h:334
unsigned srcFrameWidth
Definition: vconvert.h:333
unsigned srcFrameBytes
Definition: vconvert.h:335
BOOL PBoolean
Definition: object.h:102
unsigned GetSrcFrameWidth() const
Definition: vconvert.h:282
Array of unsigned characters.
Definition: array.h:670
PBoolean GetSrcFrameSize(unsigned &width, unsigned &height) const
Get the input frame size.
void SetVFlipState(PBoolean vFlipState)
Set the video conversion vertical flip state.
Definition: vconvert.h:109
void SetResizeMode(PVideoFrameInfo::ResizeMode mode)
Set the resize mode to be used.
Definition: vconvert.h:289
virtual PColourConverter * Create(const PVideoFrameInfo &src, const PVideoFrameInfo &dst) const =0
Define synonym colour format registration.
Definition: vconvert.h:411
const PString & GetSrcColourFormat()
Get the source colour format.
Definition: vconvert.h:187
PColourConverter(const PString &srcColourFormat, const PString &dstColourFormat, unsigned width, unsigned height)
Create a new converter.
unsigned GetSrcFrameHeight() const
Definition: vconvert.h:283
PColourConverterRegistration(const PString &srcColourFormat, const PString &destColourFormat)
virtual PBoolean SetDstFrameInfo(const PVideoFrameInfo &info)
Set the destination frame info to be used.
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.
virtual PBoolean Convert(const BYTE *, BYTE *, PINDEX *=NULL)
Convert from one colour format to another.
static bool FillYUV420P(unsigned x, unsigned y, int width, int height, unsigned frameWidth, unsigned frameHeight, BYTE *yuv, unsigned r, unsigned g, unsigned b)
PBoolean GetDstFrameSize(unsigned &width, unsigned &height) const
Get the output frame size.
Define synonym colour format converter.
Definition: vconvert.h:396
PString srcColourFormat
Definition: vconvert.h:331
This class registers a colour conversion class.
Definition: vconvert.h:56
This class defines a means to convert an image from one colour format to another. ...
Definition: vconvert.h:80
unsigned dstFrameHeight
Definition: vconvert.h:339
PINDEX GetMaxSrcFrameBytes()
Get the maximum frame size in bytes for source frames.
Definition: vconvert.h:198
unsigned dstFrameBytes
Definition: vconvert.h:340
PVideoFrameInfo::ResizeMode resizeMode
Definition: vconvert.h:342
PSynonymColourRegistration(const char *srcFmt, const char *dstFmt)
Ultimate parent class for all objects in the class library.
Definition: object.h:1118
PString dstColourFormat
Definition: vconvert.h:332
PVideoFrameInfo::ResizeMode GetResizeMode() const
Get the resize mode to be used.
Definition: vconvert.h:295
virtual PBoolean SetSrcFrameInfo(const PVideoFrameInfo &info)
Set the source frame info to be used.
struct jdec_private * jdec
Definition: vconvert.h:350