audioconvert: use SPA_CLAMPF to clamp floats

It generates better assembler.
This commit is contained in:
Wim Taymans 2022-07-19 17:59:14 +02:00
parent fd46ef16ed
commit 5a8af97a40
2 changed files with 7 additions and 1 deletions

View file

@ -147,6 +147,12 @@ struct spa_fraction {
SPA_MIN(SPA_MAX(_v, _low), _high); \ SPA_MIN(SPA_MAX(_v, _low), _high); \
}) })
#define SPA_CLAMPF(v,low,high) \
({ \
fminf(fmaxf(v, low), high); \
})
#define SPA_SWAP(a,b) \ #define SPA_SWAP(a,b) \
({ \ ({ \
__typeof__(a) _t = (a); \ __typeof__(a) _t = (a); \

View file

@ -40,7 +40,7 @@
#define ITOF(type,v,scale,offs) \ #define ITOF(type,v,scale,offs) \
(((type)(v)) * (1.0f / (scale)) - (offs)) (((type)(v)) * (1.0f / (scale)) - (offs))
#define FTOI(type,v,scale,offs,noise,min,max) \ #define FTOI(type,v,scale,offs,noise,min,max) \
(type)f32_round(SPA_CLAMP((v) * (scale) + (offs) + (noise), min, max)) (type)f32_round(SPA_CLAMPF((v) * (scale) + (offs) + (noise), min, max))
#define FMT_OPS_MAX_ALIGN 32 #define FMT_OPS_MAX_ALIGN 32