Skip to content

Commit dcb6cb5

Browse files
authored
Revert "VX_RPP - Fixing Resample build issue (#1416)" (#1417)
This reverts commit ce77dc7.
1 parent ce77dc7 commit dcb6cb5

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

amd_openvx_extensions/amd_rpp/source/tensor/Resample.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,40 @@ struct ResampleLocalData {
4040
size_t outputTensorDims[RPP_MAX_TENSOR_DIMS];
4141
};
4242

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+
4377
void update_destination_roi(ResampleLocalData *data, RpptROI *src_roi, RpptROI *dst_roi) {
4478
float scale_ratio;
4579
for (uint32_t i = 0; i < data->pSrcDesc->n; i++) {

0 commit comments

Comments
 (0)