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
00032
00033
00034
00035
00036
00037
00038
#ifndef _VRSKIPPINGSINK_H_
00039
#define _VRSKIPPINGSINK_H_
00040
00041
#include <VrSink.h>
00042
#include <stdio.h>
00043
#include <assert.h>
00044
00045
00046
00047
00048
00049
template<
class iType>
00050 class VrSkippingSink :
public VrSink<iType> {
00051
protected:
00052 unsigned int history;
00053 unsigned int increment;
00054
public:
00055
00056
00057
00058 VrSkippingSink() : history(1), increment(1) {
00059
setOptimalSize(1);
00060 }
00061
00062 virtual void pre_initialize () {
00063
if (increment <= 0) {
00064 fprintf (stderr,
"[%s:%d] initialize() invalid value for increment=%d\n",
00065 __FILE__, __LINE__, increment);
00066 abort ();
00067 }
00068
00069
if (increment == 1){
00070 fprintf (stderr,
"### Warning: increment == 1 in pre_initialize of %s. Are you sure?\n",
00071 name ());
00072 }
00073
00074
setSamplingFrequency(getInputSamplingFrequencyN (0) / increment);
00075 }
00076
00077
virtual int forecast(
VrSampleRange output,
00078
VrSampleRange inputs[]);
00079
00080 virtual float averageInputUse(
int n) {
00081
if(increment>history)
return (
float) history/(
float) increment;
00082
else return 1.0;
00083 }
00084
00085 virtual unsigned int mapSizeUp(
int i,
unsigned int size) {
00086
return (
unsigned int) (size *
averageInputUse(i) *
00087 (
getUpstreamModuleN(i)->
getSamplingFrequency()
00088 /
getSamplingFrequency()));
00089 }
00090
00091 virtual ~VrSkippingSink() {}
00092 };
00093
00094
template<
class iType>
int
00095 VrSkippingSink<iType>::forecast(
VrSampleRange output,
00096
VrSampleRange inputs[]) {
00097
00098
00099 assert (output.
size == 1);
00100
00101
for(
unsigned int i=0;i<numberInputs;i++) {
00102 inputs[i].
index=output.
index*
increment;
00103 inputs[i].
size=
history;
00104 }
00105
return 0;
00106 }
00107
00108
#endif
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127