Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
utils.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024 OWL Services LLC. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
13#ifndef INCLUDE_ZEPHYR_DSP_UTILS_H_
14#define INCLUDE_ZEPHYR_DSP_UTILS_H_
15
16#include <stdint.h>
17#include <zephyr/kernel.h>
18#include <zephyr/dsp/dsp.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
46#define Z_SHIFT_Q7_TO_F32(src, m) ((float32_t)(((src << m)) / (float32_t)(1U << 7)))
47
55#define Z_SHIFT_Q15_TO_F32(src, m) ((float32_t)((src << m) / (float32_t)(1U << 15)))
56
64#define Z_SHIFT_Q31_TO_F32(src, m) ((float32_t)(((int64_t)src) << m) / (float32_t)(1U << 31))
65
73#define Z_SHIFT_Q7_TO_F64(src, m) (((float64_t)(src << m)) / (1U << 7))
74
82#define Z_SHIFT_Q15_TO_F64(src, m) (((float64_t)(src << m)) / (1UL << 15))
83
91#define Z_SHIFT_Q31_TO_F64(src, m) ((float64_t)(((int64_t)src) << m) / (1ULL << 31))
92
114#define Z_SHIFT_F32_TO_Q7(src, m) \
115 ((q7_t)Z_CLAMP((int32_t)(src * (1U << 7)) >> m, INT8_MIN, INT8_MAX))
116
124#define Z_SHIFT_F32_TO_Q15(src, m) \
125 ((q15_t)Z_CLAMP((int32_t)(src * (1U << 15)) >> m, INT16_MIN, INT16_MAX))
126
134#define Z_SHIFT_F32_TO_Q31(src, m) \
135 ((q31_t)Z_CLAMP((int64_t)(src * (1U << 31)) >> m, INT32_MIN, INT32_MAX))
136
144#define Z_SHIFT_F64_TO_Q7(src, m) \
145 ((q7_t)Z_CLAMP((int32_t)(src * (1U << 7)) >> m, INT8_MIN, INT8_MAX))
146
154#define Z_SHIFT_F64_TO_Q15(src, m) \
155 ((q15_t)Z_CLAMP((int32_t)(src * (1U << 15)) >> m, INT16_MIN, INT16_MAX))
156
164#define Z_SHIFT_F64_TO_Q31(src, m) \
165 ((q31_t)Z_CLAMP((int64_t)(src * (1U << 31)) >> m, INT32_MIN, INT32_MAX))
166
171#ifdef __cplusplus
172}
173#endif
174
175#endif /* INCLUDE_ZEPHYR_DSP_UTILS_H_ */
Public APIs for Digital Signal Processing (DSP) math.
Public kernel APIs.