Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

videoformat.hh

00001 /*
00002  * PIAVE - PIAVE Is A Video Editor
00003  *
00004  * Copyright (C) 2002 Rolf Dubitzky, rolf@dubitzky.de
00005  */
00006 
00007 /*
00008  * This program is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software Foundation,
00020  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00021  */
00022 
00037 #if ! defined ( VIDEOFORMAT_HH )
00038 #define VIDEOFORMAT_HH
00039 
00040 // std c
00041 #include <stdint.h>
00042 
00043 // std c++
00044 #include <string>
00045 #include <vector>
00046 
00047 namespace PIAVE {
00048 
00049     struct FOURCC {
00050         explicit FOURCC( uint32_t c = 0 ) : fourcc( c ) {};
00051         explicit FOURCC( const char c[5] ) : 
00052           fourcc( (c[0]) + (c[1]<<8) + (c[2]<<16) + (c[3]<<24) ) {}
00053 
00054          bool operator==( const FOURCC & o ) const { 
00055             return o.fourcc==fourcc; }
00056          bool operator!=( const FOURCC & o ) const { 
00057             return !(o.fourcc==fourcc); }
00058         std::string toString() const;
00059 
00060         uint32_t fourcc;
00061         static const FOURCC NONE;
00062         static const FOURCC RGB;
00063         static const FOURCC YUY2;
00064     };
00065     std::ostream& operator<<( std::ostream&, const FOURCC& );
00066 
00067 
00068     class PixFmt {
00069       public:
00070 
00071         enum alpha_e { flat, alpha };
00072 
00073         PixFmt( FOURCC fourcc, alpha_e alpha = flat ) :
00074           _fourcc( fourcc ), _alpha( alpha ) {};
00075 
00076         alpha_e getAlpha() const { return _alpha; }
00077         FOURCC getFOURCC() const { return _fourcc; }
00078 
00079         bool operator == ( const PixFmt & o ) const {
00080             return (_fourcc==o._fourcc && _alpha==o._alpha); }
00081 
00082         PixFmt & operator = ( const PixFmt & o ) {
00083             _fourcc=o._fourcc; _alpha==o._alpha; return (*this); }
00084 
00085       private:
00086         FOURCC     _fourcc;
00087         alpha_e    _alpha;
00088 
00089       public:
00090         static const PixFmt NONE;
00091         static const PixFmt RGB;
00092         static const PixFmt RGB_A;
00093         static const PixFmt YUY2;
00094         static const PixFmt YUY2_A;
00095 
00096     };
00097     std::ostream& operator<<( std::ostream&, const PixFmt& );
00098 
00099 
00100     class VideoFmt
00101     {
00102       public:
00103         VideoFmt() : width( 0 ), height( 0 ), 
00104                      aspect( -1 ), fps( -1 ), fourcc( FOURCC::NONE ) {}
00105         double         getFrameLength() const { return 1.0/fps; }
00106         unsigned int   width;
00107         unsigned int   height;
00108         double         aspect;
00109         double         fps;      //   <0 :  means non-fixed
00110         FOURCC         fourcc;
00111     };
00112 
00113 }
00114 
00115             
00116 #endif

Generated on Tue Oct 14 20:45:37 2003 for piave by doxygen1.2.18