Sound Open Firmware
Loading...
Searching...
No Matches
format.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 *
3 * Copyright(c) 2016 - 2023 Intel Corporation. All rights reserved.
4 *
5 * Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
6 * Liam Girdwood <liam.r.girdwood@linux.intel.com>
7 * Keyon Jie <yang.jie@linux.intel.com>
8 * Adrian Warecki <adrian.warecki@intel.com>
9 */
10
17#ifndef __MODULE_AUDIO_FORMAT_H__
18#define __MODULE_AUDIO_FORMAT_H__
19
20#include <stdint.h>
21#include "../ipc/stream.h"
22
28static inline uint32_t get_sample_bytes(enum sof_ipc_frame fmt)
29{
30 switch (fmt) {
32 return 2;
34 return 3;
38 return 1;
39 default:
40 return 4;
41 }
42}
43
49static inline uint32_t get_sample_bitdepth(enum sof_ipc_frame fmt)
50{
51 switch (fmt) {
53 return 16;
56 return 24;
60 return 8;
61 default:
62 return 32;
63 }
64}
65
72static inline uint32_t get_frame_bytes(enum sof_ipc_frame fmt, uint32_t channels)
73{
74 return get_sample_bytes(fmt) * channels;
75}
76
77#endif /* __MODULE_AUDIO_FORMAT_H__ */
static uint32_t get_sample_bytes(enum sof_ipc_frame fmt)
Get the byte size of a single audio sample for a given frame format.
Definition format.h:28
static uint32_t get_frame_bytes(enum sof_ipc_frame fmt, uint32_t channels)
Get the byte size of an entire multi-channel audio frame.
Definition format.h:72
static uint32_t get_sample_bitdepth(enum sof_ipc_frame fmt)
Get the bit depth of a single audio sample for a given frame format.
Definition format.h:49
sof_ipc_frame
Definition stream.h:16
@ SOF_IPC_FRAME_A_LAW
Definition stream.h:26
@ SOF_IPC_FRAME_S24_4LE
Definition stream.h:18
@ SOF_IPC_FRAME_S24_3LE
Definition stream.h:22
@ SOF_IPC_FRAME_S16_LE
Definition stream.h:17
@ SOF_IPC_FRAME_MU_LAW
Definition stream.h:27
@ SOF_IPC_FRAME_U8
Definition stream.h:24