00001
00002
00003
00004
00005
00006
00007
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;
00019 const unsigned short VYA_MAX_BITS_U = 15;
00020 const unsigned short VYA_MAX_BITS_S = 16;
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};
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
00091 inline int VYAclip (int data, int min, int max) {
00092 return ((data < min) ? min : (data > max) ? max : data);
00093 }
00094
00095
00096
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
00104
00105 inline int VYAtruncate (int data, int n) {
00106 return ((data < 0) ? ((data >> n) + 1) : (data >> n));
00107 }
00108
00109
00110
00111 inline int VYAdivBinary (int data, int n) {
00112 return (data >> n);
00113 }
00114
00115
00116
00117 inline int VYAmodBinary (int data, int n) {
00118 return (data & ((1 << n) - 1));
00119 }
00120
00121 #endif