/** * @class vetFrameYUV420 * * @brief This Class implements standard VETLib I/O Frame format. * An image consisting of red, green and blue pixels. * PixelRGB24 Array [width*height] (raster scan) * Currently PixelRGB24 is difined as 3 char (3 * 8 = 24bits) * * * @see PixelRGB24 * @see vetFrame * * @version 0.6 * @date 12/07/2005 - //2005 * @author Alessandro Polo * * **************************************************************************** * VETLib Framework 1.0.2 * Copyright (C) Alessandro Polo 2006 * http://www.ewgate.net/vetlib * ****************************************************************************/ //http://www.fourcc.org #ifndef __VETLIB_VETFRAMEYUV420_H__ #define __VETLIB_VETFRAMEYUV420_H__ #define _VETFRAMECACHE24_SLOWMODE #include "vetDefs.h" #include "vetFrame.h" class vetFrameYUV420; #include "vetFrameRGB24.h" // PLANAR PLANAR PLANAR PLANAR PLANAR PLANAR PLANAR PLANAR PLANAR PLANAR PLANAR class vetFrameYUV420 : public virtual vetFrame { public: bool autoFreeData; /** * @var PLANAR YUV data array pointer. Size is width * height * 3. */ unsigned char *data; unsigned char *Y; // = data[0] unsigned char *U; // = data[ width*height* ] unsigned char *V; // = data[ width*height*1.25 ] public: /** * @var Enumerate available Channels. */ enum ChannelYUV { Lum, Cb, Cr }; // YUV /** * @brief Default constructor, initialize height and width to 0. */ vetFrameYUV420(); /** * @brief Create an image with the given dimensions, allocates (random) data. * @param width Width of the image. * @param height Height of the image. */ vetFrameYUV420(unsigned int width, unsigned int height); /** * @brief Copy Constructor, create an image from another image, copying memory. * @param img source image. */ vetFrameYUV420(vetFrameYUV420& img); /** * @brief Destructor currenly clear pixel data (array). */ ~vetFrameYUV420(); void* dump_buffer() { return static_cast(data); }; VETRESULT reAllocCanvas(unsigned int w, unsigned int h); //width*height*1.5 * 8bit / width/height = 1.5*8bit = 12bit unsigned int getBpp() { return 12; }; VETRESULT setBlack(); VETRESULT setWhite(); VETRESULT extractBrightness(unsigned char* buffer, unsigned int* size = NULL ); unsigned int getBufferSize() { return (unsigned int)( width * height * 1.5); }; /** * @brief Clear all pixel to the specified value. * * @param bg a PixelRGB to overwrite on all image. * * @return current instance address. */ vetFrameYUV420& clearWith(unsigned char* bg, ChannelYUV channel); /** * @brief Set pixel (x, y) to the specified value. * * @param x x position of the pixel. * @param y y position of the pixel. * @param p new value for the selected coords. * * @note No check is made that x and y are in range. */ VETRESULT setPixel(unsigned int x, unsigned int y, unsigned char& value, ChannelYUV channel); /** * @brief Get pixel (x, y) value and store it to p. * * @param x x position of the pixel. * @param y y position of the pixel. * @param p address to store selected pixel's value. * * @note No check is made that x and y are in range. */ VETRESULT getPixel(unsigned int x, unsigned int y, unsigned char& value, ChannelYUV channel); /** * @brief Copies all pixel data from img. * Throws an exception if images are of different size. * * @param img The image to copy the data from. * * @return current instance. */ vetFrameYUV420& operator = (vetFrameYUV420& img); /** * @brief Overload equals-add (+=) operator for two images (pixel += loop) * Throws an exception if images are of different size. * * @param img The image to add to current data. * * @return current instance. */ vetFrameYUV420& operator += (vetFrameYUV420& img); /** * @brief Overload equals-add (+=) operator for two images (pixel += loop) * Throws an exception if images are of different size. * * @param img The image to add to current data. * * @return current instance. */ vetFrameYUV420& operator *= (vetFrameYUV420& img); void operator << (const vetFrameRGB24& img); vetFrameYUV420& operator >> (vetFrameRGB24& img); VETFRAME_PROFILE getProfile() { return vetFrame::VETFRAME_I420; }; VETFRAME_CHANNEL_TYPE getChannelType() { return vetFrame::VETFRAME_CT_PLANAR; }; int getFOURCC() { return 0x30323449; }; }; #endif //__VETLIB_VETFRAMEYUV420_H__