Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

vconvert.h

Go to the documentation of this file.
00001 /* 00002 * vconvert.h 00003 * 00004 * Classes to support streaming video input (grabbing) and output. 00005 * 00006 * Portable Windows Library 00007 * 00008 * Copyright (c) 1993-2000 Equivalence Pty. Ltd. 00009 * 00010 * The contents of this file are subject to the Mozilla Public License 00011 * Version 1.0 (the "License"); you may not use this file except in 00012 * compliance with the License. You may obtain a copy of the License at 00013 * http://www.mozilla.org/MPL/ 00014 * 00015 * Software distributed under the License is distributed on an "AS IS" 00016 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00017 * the License for the specific language governing rights and limitations 00018 * under the License. 00019 * 00020 * The Original Code is Portable Windows Library. 00021 * 00022 * The Initial Developer of the Original Code is Equivalence Pty. Ltd. 00023 * 00024 * Contributor(s): Derek Smithies (derek@indranet.co.nz) 00025 * Thorsten Westheider (thorsten.westheider@teleos-web.de) 00026 * Mark Cooke (mpc@star.sr.bham.ac.uk) 00027 * 00028 * $Log: vconvert.h,v $ 00029 * Revision 1.13 2003/03/17 07:44:20 robertj 00030 * Removed redundant toggle function. 00031 * 00032 * Revision 1.12 2002/09/16 01:08:59 robertj 00033 * Added #define so can select if #pragma interface/implementation is used on 00034 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00035 * 00036 * Revision 1.11 2002/01/04 04:11:45 dereks 00037 * Add video flip code from Walter Whitlock, which flips code at the grabber. 00038 * 00039 * Revision 1.10 2001/11/28 04:41:28 robertj 00040 * Added synonym colour class for equivalent colour format strings. 00041 * Allowed for setting ancestor classes in PCOLOUR_CONVERTER() macro. 00042 * 00043 * Revision 1.9 2001/05/14 05:10:38 robertj 00044 * Fixed problems with video colour converters registration, could not rely 00045 * on static PList being initialised before all registration instances. 00046 * 00047 * Revision 1.8 2001/03/20 02:21:57 robertj 00048 * More enhancements from Mark Cooke 00049 * 00050 * Revision 1.7 2001/03/08 23:36:02 robertj 00051 * Added backward compatibility SetFrameSize() function. 00052 * Added internal SimpleConvert() function for same type converters. 00053 * Fixed some documentation. 00054 * 00055 * Revision 1.6 2001/03/08 08:31:34 robertj 00056 * Numerous enhancements to the video grabbing code including resizing 00057 * infrastructure to converters. Thanks a LOT, Mark Cooke. 00058 * 00059 * Revision 1.5 2001/03/07 01:42:59 dereks 00060 * miscellaneous video fixes. Works on linux now. Add debug statements 00061 * (at PTRACE level of 1) 00062 * 00063 * Revision 1.4 2001/03/03 23:25:07 robertj 00064 * Fixed use of video conversion function, returning bytes in destination frame. 00065 * 00066 * Revision 1.3 2001/03/03 05:06:31 robertj 00067 * Major upgrade of video conversion and grabbing classes. 00068 * 00069 * Revision 1.2 2000/12/19 23:58:14 robertj 00070 * Fixed MSVC compatibility issues. 00071 * 00072 * Revision 1.1 2000/12/19 22:20:26 dereks 00073 * Add video channel classes to connect to the PwLib PVideoInputDevice class. 00074 * Add PFakeVideoInput class to generate test images for video. 00075 * 00076 * 00077 */ 00078 00079 #define _PCONVERT 00080 00081 00082 #ifdef P_USE_PRAGMA 00083 #pragma interface 00084 #endif 00085 00086 00087 00088 class PColourConverter; 00089 00095 class PColourConverterRegistration : public PCaselessString 00096 { 00097 PCLASSINFO(PColourConverterRegistration, PCaselessString); 00098 public: 00099 PColourConverterRegistration( 00100 const PString & srcColourFormat, 00101 const PString & destColourFormat 00102 ); 00103 00104 virtual PColourConverter * Create( 00105 unsigned width, 00106 unsigned height 00107 ) const = 0; 00108 00109 protected: 00110 PColourConverterRegistration * link; 00111 00112 friend class PColourConverter; 00113 }; 00114 00115 00119 class PColourConverter : public PObject 00120 { 00121 PCLASSINFO(PColourConverter, PObject); 00122 public: 00125 PColourConverter( 00126 const PString & srcColourFormat, 00127 const PString & dstColourFormat, 00128 unsigned width, 00129 unsigned height 00130 ); 00131 00134 BOOL GetVFlipState() 00135 { return doVFlip; } 00136 00139 void SetVFlipState(BOOL vFlipState) 00140 { doVFlip = vFlipState; } 00141 00146 virtual BOOL SetFrameSize( 00147 unsigned width, 00148 unsigned height 00149 ); 00150 00157 virtual BOOL SetSrcFrameSize( 00158 unsigned width, 00159 unsigned height 00160 ); 00161 00168 virtual BOOL SetDstFrameSize( 00169 unsigned width, 00170 unsigned height, 00171 BOOL bScale 00172 ); 00173 00176 const PString & GetSrcColourFormat() { return srcColourFormat; } 00177 00180 const PString & GetDstColourFormat() { return dstColourFormat; } 00181 00187 PINDEX GetMaxSrcFrameBytes() { return srcFrameBytes; } 00188 00194 PINDEX GetMaxDstFrameBytes() { return dstFrameBytes; } 00195 00196 00206 virtual BOOL Convert( 00207 const BYTE * srcFrameBuffer, 00208 BYTE * dstFrameBuffer, 00209 PINDEX * bytesReturned = NULL 00210 ) = 0; 00211 00228 virtual BOOL ConvertInPlace( 00229 BYTE * frameBuffer, 00230 PINDEX * bytesReturned = NULL, 00231 BOOL noIntermediateFrame = FALSE 00232 ); 00233 00234 00239 static PColourConverter * Create( 00240 const PString & srcColourFormat, 00241 const PString & dstColourFormat, 00242 unsigned width, 00243 unsigned height 00244 ); 00245 00248 BOOL GetDstFrameSize( 00249 unsigned & width, 00250 unsigned & height 00251 ) const; 00252 00255 BOOL GetSrcFrameSize( 00256 unsigned & width, 00257 unsigned & height 00258 ) const; 00259 00260 00261 protected: 00262 PString srcColourFormat; 00263 PString dstColourFormat; 00264 unsigned srcFrameWidth; 00265 unsigned srcFrameHeight; 00266 unsigned srcFrameBytes; 00267 unsigned dstFrameBytes; 00268 00269 // Needed for resizing 00270 unsigned dstFrameWidth; 00271 unsigned dstFrameHeight; 00272 BOOL scaleNotCrop; 00273 00274 BOOL doVFlip; 00275 00276 PBYTEArray intermediateFrameStore; 00277 00278 friend class PColourConverterRegistration; 00279 }; 00280 00281 00287 #define PCOLOUR_CONVERTER2(cls,ancestor,src,dst) \ 00288 class cls : public ancestor { \ 00289 public: \ 00290 cls(const PString & srcFmt, const PString & dstFmt, unsigned w, unsigned h) \ 00291 : ancestor(srcFmt, dstFmt, w, h) { } \ 00292 virtual BOOL Convert(const BYTE *, BYTE *, PINDEX * = NULL); \ 00293 }; \ 00294 static class cls##_Registration : public PColourConverterRegistration { \ 00295 public: \ 00296 cls##_Registration() \ 00297 : PColourConverterRegistration(src,dst) { } \ 00298 virtual PColourConverter * Create(unsigned w, unsigned h) const; \ 00299 } p_##cls##_registration_instance; \ 00300 PColourConverter * cls##_Registration::Create(unsigned w, unsigned h) const \ 00301 { PINDEX tab = Find('\t'); return new cls(Left(tab), Mid(tab+1), w, h); } \ 00302 BOOL cls::Convert(const BYTE *srcFrameBuffer, BYTE *dstFrameBuffer, PINDEX * bytesReturned) 00303 00304 00310 #define PCOLOUR_CONVERTER(cls,src,dst) \ 00311 PCOLOUR_CONVERTER2(cls,PColourConverter,src,dst) 00312 00313 00314 00319 class PSynonymColour : public PColourConverter { 00320 public: 00321 PSynonymColour( 00322 const PString & srcFmt, 00323 const PString & dstFmt, 00324 unsigned w, unsigned h 00325 ) : PColourConverter(srcFmt, dstFmt, w, h) { } 00326 virtual BOOL Convert(const BYTE *, BYTE *, PINDEX * = NULL); 00327 }; 00328 00329 00334 class PSynonymColourRegistration : public PColourConverterRegistration { 00335 public: 00336 PSynonymColourRegistration( 00337 const char * srcFmt, 00338 const char * dstFmt 00339 ) : PColourConverterRegistration(srcFmt,dstFmt) { } 00340 virtual PColourConverter * Create(unsigned w, unsigned h) const; 00341 }; 00342 00343 00348 #define PSYNONYM_COLOUR_CONVERTER(from,to) \ 00349 static PSynonymColourRegistration p_##from##_##to##_registration_instance(#from,#to) 00350 00351 00352 // End of file ///////////////////////////////////////////////////////////////

Generated on Sat Jul 24 15:35:57 2004 for PWLib by doxygen 1.3.7