Doxygen Source Code Documentation
Main Page Alphabetical List Data Structures File List Data Fields Globals Search
vp_util.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "vp_global.h"
00032
00033
00034
00035
00036
00037
00038
00039 vpResult
00040 vpRamp(dst, stride, num_points, ramp_x, ramp_y)
00041 float *dst;
00042 int stride;
00043 int num_points;
00044 int *ramp_x;
00045 float *ramp_y;
00046 {
00047 int i, x;
00048 int lastx, nextx;
00049 double lasty, nexty, dydx, y;
00050
00051 if (num_points < 1)
00052 return(VPERROR_BAD_VALUE);
00053 for (i = 1; i < num_points; i++)
00054 if (ramp_x[i] <= ramp_x[i-1])
00055 return(VPERROR_BAD_VALUE);
00056 dst[*ramp_x * stride/sizeof(float)] = *ramp_y;
00057 if (num_points == 1)
00058 return(VP_OK);
00059 for (i = 1; i < num_points; i++) {
00060 lastx = ramp_x[i-1];
00061 lasty = ramp_y[i-1];
00062 nextx = ramp_x[i];
00063 nexty = ramp_y[i];
00064 dydx = (double)(nexty - lasty) / (double)(nextx - lastx);
00065 for (x = lastx+1, y = lasty+dydx; x < nextx; x++, y += dydx)
00066 dst[x * stride/sizeof(float)] = y;
00067 dst[x * stride/sizeof(float)] = nexty;
00068 }
00069 return(VP_OK);
00070 }
00071
00072
00073
00074
00075
00076
00077
00078
00079 #ifdef ANSI_C
00080 void
00081 VPBug(char *fmt, ...)
00082 #else
00083 void
00084 VPBug(fmt, va_alist)
00085 char *fmt;
00086 va_dcl
00087 #endif
00088 {
00089 va_list args;
00090 extern void exit ANSI_ARGS((int status));
00091
00092 fprintf(stderr, "BUG: ");
00093 #ifdef ANSI_C
00094 va_start(args, fmt);
00095 #else
00096 va_start(args);
00097 #endif
00098 #ifdef HAVE_VPRINTF
00099 vfprintf(stderr, fmt, args);
00100 #else
00101 #ifdef HAVE_DOPRNT
00102 _doprnt(fmt, args, stderr);
00103 #else
00104 fprintf(stderr, "unrecoverable error");
00105 #endif
00106 #endif
00107 va_end(args);
00108 fprintf(stderr, "\n");
00109 exit(1);
00110 }
00111
00112 #ifdef DEBUG
00113
00114
00115
00116
00117
00118
00119
00120 #ifdef ANSI_C
00121 void
00122 VPDebug(vpContext *vpc, int debug_code, char *fmt, ...)
00123 #else
00124 void
00125 VPDebug(vpc, debug_code, fmt, va_alist)
00126 vpContext *vpc;
00127 int debug_code;
00128 char *fmt;
00129 va_dcl
00130 #endif
00131 {
00132 va_list args;
00133
00134 if (vpc->debug_enable[debug_code]) {
00135 #ifdef ANSI_C
00136 va_start(args, fmt);
00137 #else
00138 va_start(args);
00139 #endif
00140 #ifdef HAVE_VPRINTF
00141 vfprintf(stdout, fmt, args);
00142 #else
00143 #ifdef HAVE_DOPRNT
00144 _doprnt(fmt, args, stdout);
00145 #else
00146 printf("unrecoverable error");
00147 #endif
00148 #endif
00149 va_end(args);
00150 }
00151 }
00152 #endif