Main Page | Compound List | File List | Compound Members | File Members

vya.cc

Go to the documentation of this file.
00001 /*--------------------------------------------------------------------
00002  *
00003  * (C) Copyright Koninklijke Philips Electronics NV 2006. 
00004  * All rights reserved. This software is licensed under the terms of
00005  * version 2.1 of the GNU Lesser General Public License as published 
00006  * by the Free Software Foundation. For licensing and warranty
00007  * information, see the file COPYING in the main directory.
00008  *
00009  *------------------------------------------------------------------*/
00010 
00011 #include "vya.h"
00012 
00013 VYAbitPrecision::VYAbitPrecision()
00014 {
00015     bits    = 8;
00016     signbit = false;
00017 }
00018 
00019 VYAbitPrecision::VYAbitPrecision(const VYAbitPrecision& newBitPrec)
00020 {
00021     bits    = newBitPrec.bits;
00022     signbit = newBitPrec.signbit;
00023 }
00024 
00025 VYAbitPrecision::VYAbitPrecision(unsigned int Bits, bool Signbit)
00026 {
00027     bits    = Bits;
00028     signbit = Signbit;
00029 }
00030 
00031 VYAprocess::VYAprocess(Id n) : Process(n)
00032 {
00033 }
00034 
00035 VYAprocess::~VYAprocess()
00036 {
00037 }
00038 
00039 void VYAprocess::VYAcheckPrecision(const char *fullName,
00040                      VYAbitPrecision inPrec, VYAbitPrecision outPrec,
00041                      unsigned int minInBits, unsigned int maxInBits,
00042                      bool inSigned, bool outSigned)
00043 {
00044     bool error = false;
00045 
00046     // check input bit precision
00047     if (inPrec.bits < VYA_MIN_BITS) {
00048         printf("precision error in process %s:\n",fullName);
00049         printf("inBits too small: %d; must be >= %d\n",inPrec.bits,VYA_MIN_BITS);
00050         error = true;
00051     }
00052     if (inPrec.signbit && (inPrec.bits > VYA_MAX_BITS_S)) {
00053         printf("precision error in process %s:\n",fullName);
00054         printf("inBits too large: %d; must be <= %d for signed data\n",inPrec.bits,VYA_MAX_BITS_S);
00055        error = true;
00056     }
00057     if (!inPrec.signbit && (inPrec.bits > VYA_MAX_BITS_U)) {
00058         printf("precision error in process %s:\n",fullName);
00059         printf("inBits too large: %d; must be <= %d for signed data\n",inPrec.bits,VYA_MAX_BITS_U);
00060         error = true;
00061     }
00062     if ((inPrec.bits < minInBits) || (inPrec.bits > maxInBits) ||
00063         (inPrec.signbit != inSigned)) {
00064         printf("precision error in process %s:\n",fullName);
00065         printf("inBits    = %d; minInBits = %d; maxInBits = %d\n",inPrec.bits,minInBits,maxInBits);
00066         printf("inSigned  = %d; should be   %d\n",inPrec.signbit,inSigned);
00067         error = true;
00068      }
00069 
00070     // check output bit precision
00071     if (outPrec.bits < VYA_MIN_BITS) {
00072         printf("precision error in process %s:\n",fullName);
00073         printf("outBits too small: %d; must be >= %d\n",outPrec.bits,VYA_MIN_BITS);
00074         error = true;
00075     }
00076     if (outPrec.signbit && (outPrec.bits > VYA_MAX_BITS_S)) {
00077         printf("precision error in process %s:\n",fullName);
00078         printf("outBits too large: %d; must be <= %d for signed data\n",outPrec.bits,VYA_MAX_BITS_S);
00079         error = true;
00080     }
00081     if (!outPrec.signbit && (outPrec.bits > VYA_MAX_BITS_U)) {
00082         printf("precision error in process %s:\n",fullName);
00083         printf("outBits too large: %d; must be <= %d for signed data\n",outPrec.bits,VYA_MAX_BITS_U);
00084         error = true;
00085     }
00086     if (outPrec.signbit != outSigned) {
00087         printf("sign error in process %s:\n",fullName);
00088         printf("outSigned = %d; should be   %d\n",outPrec.signbit,outSigned);
00089         error = true;
00090     }
00091 
00092     if (error)
00093         exit(1);
00094 }
00095 
00096 // check line length only
00097 void VYAprocess::VYAcheckLineLength(const char *fullName,
00098                      VYApixel **lineBuffer,
00099                      VYAlineLength len,    VYAlineLength *oldLen,
00100                      VYAlineLength minLen, VYAlineLength maxLen)
00101 {
00102     if ((len < minLen) || (len > maxLen)) {
00103         printf("size error in process %s:\n",fullName);
00104         printf("  lineLen    = %d  minLineLen = %d  maxLineLen = %d\n",len,minLen,maxLen);
00105         exit(1);
00106     }
00107     if (len != *oldLen) {              // line length change
00108         *oldLen = len;
00109         if (*lineBuffer != NULL)
00110             delete *lineBuffer;        // release old buffer
00111         *lineBuffer = new VYApixel[len];
00112     }
00113 }
00114 
00115 // check image width only
00116 void VYAprocess::VYAcheckImageWidth(const char *fullName,
00117                      VYApixel **lineBuffer,
00118                      VYAimageWidth width,    VYAimageWidth *oldWidth,
00119                      VYAimageWidth minWidth, VYAimageWidth maxWidth)
00120 {
00121     if ((width < minWidth) || (width > maxWidth)) {
00122         printf("size error in process %s:\n",fullName);
00123         printf("  imgWidth    = %d  minImgWidth = %d  maxImgWidth = %d\n",width,minWidth,maxWidth);
00124         exit(1);
00125     }
00126     if (width != *oldWidth) {          // image width change
00127         *oldWidth = width;
00128         if (*lineBuffer != NULL)
00129             delete *lineBuffer;        // release old buffer
00130         *lineBuffer = new VYApixel[width];
00131     }
00132 }
00133 
00134 // check image height only
00135 void VYAprocess::VYAcheckImageHeight(const char *fullName,
00136                      VYAimageHeight height,    VYAimageHeight *oldHeight,
00137                      VYAimageHeight minHeight, VYAimageHeight maxHeight)
00138 {
00139     if ((height < minHeight) || (height > maxHeight)) {
00140         printf("size error in process %s:\n",fullName);
00141         printf("  imgHeight   = %d  minImgHeight = %d  maxImgHeight = %d\n",height,minHeight,maxHeight);
00142         exit(1);
00143     }
00144     if (height != *oldHeight) {        // image height change
00145         *oldHeight = height;
00146     }
00147 }
00148 
00149 // check image width and image height
00150 void VYAprocess::VYAcheckImageSize(const char *fullName,
00151                      VYApixel **imageBuffer,
00152                      VYAimageWidth  width,     VYAimageWidth  *oldWidth,
00153                      VYAimageWidth  minWidth,  VYAimageWidth  maxWidth,
00154                      VYAimageHeight height,    VYAimageHeight *oldHeight,
00155                      VYAimageHeight minHeight, VYAimageHeight maxHeight)
00156 {
00157     if ((width < minWidth) || (height < minHeight) ||
00158         (width > maxWidth) || (height > maxHeight)) {
00159         printf("size error in process %s:\n",fullName);
00160         printf("  imgWidth    = %d  minImgWidth  = %d  maxImgWidth  = %d\n",width,minWidth,maxWidth);
00161         printf("  imgHeight   = %d  minImgHeight = %d  maxImgHeight = %d\n",height,minHeight,maxHeight);
00162         exit(1);
00163     }
00164     if ((width != *oldWidth) || (height != *oldHeight)) {   // image size change
00165         *oldWidth = width;
00166         *oldHeight = height;
00167         if (*imageBuffer != NULL)
00168             delete *imageBuffer;                            // release old buffer
00169         *imageBuffer = new VYApixel[width*height];
00170     }
00171 }

Generated on Wed Feb 15 14:52:42 2006 for vya by doxygen 1.3.2