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

vya.h

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 #ifndef VYA_H
00012 #define VYA_H
00013 
00014 #include <stdio.h>
00015 #include "architecture.h"
00016 #include "yapi.h"
00017 
00018 const unsigned short VYA_MIN_BITS   =  6; // minimum bit precision
00019 const unsigned short VYA_MAX_BITS_U = 15; // maximum bit precision for unsigned data
00020 const unsigned short VYA_MAX_BITS_S = 16; // maximum bit precision for signed data
00021 
00022 typedef VYAsigned16bit   VYApixel;
00023 typedef unsigned int     VYAlineLength;
00024 typedef unsigned int     VYAimageWidth;
00025 typedef unsigned int     VYAimageHeight;
00026 
00027 class VYAfileName
00028 {
00029 public:
00030   VYAfileName()                     { sprintf(name, "%s", ""); }
00031   VYAfileName(const char* n)        { sprintf(name, "%s", n); }
00032   VYAfileName(const VYAfileName& n) { sprintf(name, "%s", n.name); }
00033   operator char*()                  { return name; }
00034 private:
00035   char name[256];
00036 };
00037 
00038 enum  VYAimageType  {VYA_TOP_FIELD, VYA_BOTTOM_FIELD, VYA_FRAME};
00039 enum  VYAimageSync  {VYA_VALID, VYA_NOT_VALID}; //not valid for suppressed frames in open gop
00040 
00041 class VYAbitPrecision
00042 {
00043 public:
00044         VYAbitPrecision();
00045         VYAbitPrecision(const VYAbitPrecision&);
00046         VYAbitPrecision(unsigned int, bool);
00047 
00048         unsigned int  bits;
00049         bool          signbit;
00050 };
00051 
00052 class VYAprocess: public Process
00053 {
00054 public:
00055         VYAprocess(Id n);
00056         virtual ~VYAprocess();
00057 
00058         void VYAcheckPrecision(const char *fullName,
00059                                 VYAbitPrecision inPrec, VYAbitPrecision outPrec,
00060                                 unsigned int minInBits, unsigned int maxInBits,
00061                                 bool inSigned, bool outSigned
00062         );
00063 
00064         void VYAcheckLineLength(const char *fullName,
00065                         VYApixel **lineBuffer,
00066                         VYAlineLength len,    VYAlineLength *oldLen,
00067                         VYAlineLength minLen, VYAlineLength maxLen
00068         );
00069 
00070         void VYAcheckImageWidth(const char *fullName,
00071                         VYApixel **lineBuffer,
00072                         VYAimageWidth width,    VYAimageWidth *oldWidth,
00073                         VYAimageWidth minWidth, VYAimageWidth maxWidth
00074         );
00075 
00076         void VYAcheckImageHeight(const char *fullName,
00077                         VYAimageHeight height,    VYAimageHeight *oldHeight,
00078                         VYAimageHeight minHeight, VYAimageHeight maxHeight
00079         );
00080 
00081         void VYAcheckImageSize(const char *fullName,
00082                         VYApixel **imageBuffer,
00083                         VYAimageWidth  width,     VYAimageWidth  *oldWidth,
00084                         VYAimageWidth  minWidth,  VYAimageWidth  maxWidth,
00085                         VYAimageHeight height,    VYAimageHeight *oldHeight,
00086                         VYAimageHeight minHeight, VYAimageHeight maxHeight
00087         );
00088 };
00089 
00090 // Clip integer data to range specified by minimum and maximum values
00091 inline int VYAclip (int data, int min, int max) {
00092         return ((data < min) ? min : (data > max) ? max : data);
00093 }
00094 
00095 // Round and normalize integer data by n bits
00096 // {s.31-x.x} --> {s.31-x+n.x-n}
00097 inline int VYAroundNorm (int data, int n) {
00098         return ((n <= 0) ? (data << (-n)) :
00099                 ((data < 0) ? (-((-(data) + (1 << (n - 1))) >> n)) :
00100                               ((data + (1 << (n - 1))) >> n)));
00101 }
00102 
00103 // Truncate integer data towards zero by lower n bits
00104 // {s.31-x.x} --> {s.31-x+n.x-n}
00105 inline int VYAtruncate (int data, int n) {
00106         return ((data < 0) ? ((data >> n) + 1) : (data >> n));
00107 }
00108 
00109 // Truncate integer data by lower n bits with sign extension
00110 // {s.31-x.x} --> {s.31-x+n.x-n}
00111 inline int VYAdivBinary (int data, int n) {
00112         return (data >> n);
00113 }
00114 
00115 // Truncate integer data to lower n bits with leading zeros
00116 // {s.31-x.x} --> {s.31-n.n}
00117 inline int VYAmodBinary (int data, int n) {
00118         return (data & ((1 << n) - 1));
00119 }
00120 
00121 #endif

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