/****************************************************************************/ /* This is the source file for my frame C++ class, which is part of my */ /* Mpeg editor programme. */ /* */ /* This class desribes a YUV frame, with subsampled Cr & Cb frames, as used */ /* in Mpeg. */ /* (c)1994 Alexis 'Milamber' Ashley */ /****************************************************************************/ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __FRAME__ #define __FRAME__ #include "typedefs.H" #include #include class frame { private: struct plane { unsigned int height; unsigned int width; unsigned long int length; byte *data; } _Lum, _Cr, _Cb; static const long preamble; public: frame(unsigned int height, unsigned int width); // Normal constructor frame(unsigned int height, unsigned int width,byte lum,byte cr,byte cb); // As above + sets vals frame(const frame &); // Copy constructor ~frame(void); // Destructor bool set_lum(const byte *); // copies the bytes pointed to into lum. plane bool set_Cr(const byte *); // copies the bytes pointed to into Cr plane bool set_Cb(const byte *); // copies the bytes pointed to into Cb plane unsigned int height(void) const; // Returns height of lum plane (in pixels) unsigned int width(void) const; // Returns width of lum plane (in pixels) byte *lum_ptr(void); // Returns a pointer to the lum plane byte *Cr_ptr(void); // Returns a pointer to the Cr plane byte *Cb_ptr(void); // Returns a pointer to the Cb plane byte & Lum(int x, int y) // Returns a reference to a luminance value { assert(y>=0 && y<_Lum.height); assert(x>=0 && x<_Lum.width); return _Lum.data[y*_Lum.width+x]; } byte & Cr(int x, int y) // Returns a reference to a Cr value { assert(y>=0 && y<_Cr.height); assert(x>=0 && x<_Cr.width); return _Cr.data[y*_Cr.width+x]; } byte & Cb(int x, int y) // Returns a reference to a Cb value { assert(y>=0 && y<_Cb.height); assert(x>=0 && x<_Cb.width); return _Cb.data[y*_Cb.width+x]; } frame & operator=(const frame &f); // Allows assignment, ie f1=f2; friend fstream & operator<<(fstream &fs, const frame &f); // The << operator, to allow writing to a file friend fstream & operator>>(fstream &fs, frame &f); //The >> operator, to allow reading from a file }; #endif