mirror of https://github.com/thesofproject/sof.git
DMIC: Add for format.h conversion from fractional to float
Note: Use with care since this generic macro is currently used only in host test bench for debug print commands so there are no speed or precision optimized versions yet.The cast to int64_t is not necessary for all integer types. Also float restricts precision of a 64 bit int. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This commit is contained in:
parent
787b7d1a7b
commit
1b0fc77f83
|
@ -70,6 +70,9 @@
|
|||
*/
|
||||
#define Q_CONVERT_FLOAT(f, qy) ((int)((f) * (1 << qy) + 0.5)) /* f is float */
|
||||
|
||||
/* Convert fractional Qnx.ny number x to float */
|
||||
#define Q_CONVERT_QTOF(x, ny) ((float)(x) / ((int64_t)1 << (ny)))
|
||||
|
||||
/* A more clever macro for Q-shifts */
|
||||
#define Q_SHIFT(x, src_q, dst_q) ((x)>>((src_q)-(dst_q)))
|
||||
#define Q_SHIFT_RND(x, src_q, dst_q) ((((x) >> ((src_q)-(dst_q) -1)) +1) >> 1)
|
||||
|
|
Loading…
Reference in New Issue