@@ -40,6 +40,40 @@ struct ResampleLocalData {
40
40
size_t outputTensorDims[RPP_MAX_TENSOR_DIMS];
41
41
};
42
42
43
+ inline float sinc (float x) {
44
+ x *= M_PI;
45
+ return (std::abs (x) < 1e-5f ) ? (1 .0f - x * x * (1 .0f / 6 )) : std::sin (x) / x;
46
+ }
47
+
48
+ inline double hann (double x) {
49
+ return 0.5 * (1 + std::cos (x * M_PI));
50
+ }
51
+
52
+ // initialization function used for filling the values in Resampling window (RpptResamplingWindow)
53
+ // using the coeffs and lobes value this function generates a LUT (look up table) which is further used in Resample audio augmentation
54
+ #if RPP_AUDIO
55
+ inline void windowed_sinc (RpptResamplingWindow &window, int32_t coeffs, int32_t lobes) {
56
+ float scale = 2 .0f * lobes / (coeffs - 1 );
57
+ float scale_envelope = 2 .0f / coeffs;
58
+ window.coeffs = coeffs;
59
+ window.lobes = lobes;
60
+ window.lookup .clear ();
61
+ window.lookup .resize (coeffs + 5 );
62
+ window.lookupSize = window.lookup .size ();
63
+ int32_t center = (coeffs - 1 ) * 0 .5f ;
64
+ for (int32_t i = 0 ; i < coeffs; i++) {
65
+ float x = (i - center) * scale;
66
+ float y = (i - center) * scale_envelope;
67
+ float w = sinc (x) * hann (y);
68
+ window.lookup [i + 1 ] = w;
69
+ }
70
+ window.center = center + 1 ;
71
+ window.scale = 1 .0f / scale;
72
+ window.pCenter = _mm_set1_ps (window.center );
73
+ window.pScale = _mm_set1_ps (window.scale );
74
+ }
75
+ #endif
76
+
43
77
void update_destination_roi (ResampleLocalData *data, RpptROI *src_roi, RpptROI *dst_roi) {
44
78
float scale_ratio;
45
79
for (uint32_t i = 0 ; i < data->pSrcDesc ->n ; i++) {
0 commit comments