audioconvert: add dither noise even on empty input

When we are asked to add noise bits, don't call the clear function.

Make the passthrough and clear-on-empty flags available with a new flag
field to make it more extensible.

Fixes #5260
This commit is contained in:
Wim Taymans 2026-05-14 11:19:02 +02:00
parent 4f975d0071
commit 61431dcbc0
3 changed files with 17 additions and 11 deletions

View file

@ -222,7 +222,9 @@ struct convert {
uint32_t func_cpu_flags;
const char *func_name;
unsigned int is_passthrough:1;
#define CONVERT_FLAG_PASSTHROUGH (1u<<0)
#define CONVERT_FLAG_CLEAR_ON_EMPTY (1u<<1)
uint32_t flags;
float scale;
uint32_t *random;
@ -283,6 +285,9 @@ static inline uint32_t dither_method_from_label(const char *label)
#define convert_clear(conv,...) (conv)->clear(conv, __VA_ARGS__)
#define convert_free(conv) (conv)->free(conv)
#define convert_is_passthrough(conv) SPA_FLAG_IS_SET((conv)->flags, CONVERT_FLAG_PASSTHROUGH)
#define convert_is_clear_on_empty(conv) SPA_FLAG_IS_SET((conv)->flags, CONVERT_FLAG_CLEAR_ON_EMPTY)
#define DEFINE_NOISE_FUNCTION(name,arch) \
void conv_noise_##name##_##arch(struct convert *conv, float *noise, \
uint32_t n_samples)