00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00037 #if ! defined ( VIDEOFORMAT_HH )
00038 #define VIDEOFORMAT_HH
00039
00040
00041 #include <stdint.h>
00042
00043
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;
00110 FOURCC fourcc;
00111 };
00112
00113 }
00114
00115
00116 #endif