Front Haul Interface Library update to third seed code contribution
[o-du/phy.git] / fhi_lib / lib / api / xran_compression.h
1 /******************************************************************************
2 *
3 *   Copyright (c) 2019 Intel.
4 *
5 *   Licensed under the Apache License, Version 2.0 (the "License");
6 *   you may not use this file except in compliance with the License.
7 *   You may obtain a copy of the License at
8 *
9 *       http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *   Unless required by applicable law or agreed to in writing, software
12 *   distributed under the License is distributed on an "AS IS" BASIS,
13 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *   See the License for the specific language governing permissions and
15 *   limitations under the License.
16 *
17 *******************************************************************************/
18
19 /*!
20     \file   xran_compression.h
21     \brief  External API for compading with the use BFP algorithm.
22 */
23
24 #ifndef _XRAN_COMPRESSION_H_
25 #define _XRAN_COMPRESSION_H_
26
27 #include <stdint.h>
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 /*!
34     \struct xranlib_compress_request
35     \brief Request structure containing pointer to data and its length.
36 */
37 struct xranlib_compress_request {
38     int16_t *data_in;   /*!< Pointer to data to compress. */
39     int16_t numRBs;     /*!< numRBs  */
40     int16_t compMethod; /*!< Compression method */
41     int16_t iqWidth;    /*!< Bit size */
42     int32_t len;        /*!< Length of input buffer in bytes */
43 };
44
45 /*!
46     \struct xranlib_compress_response
47     \brief Response structure containing pointer to data and its length.
48 */
49 struct xranlib_compress_response {
50     int8_t *data_out; /*!< Pointer to data after compression. */
51
52     int32_t len; /*!< Length of output data. */
53 };
54
55 /*!
56     \struct xranlib_decompress_request
57     \brief Request structure containing pointer to data and its length.
58 */
59 struct xranlib_decompress_request {
60     int8_t *data_in; /*!< Pointer to data to decompress. */
61     int16_t numRBs;     /*!< numRBs  */
62     int16_t compMethod; /*!< Compression method */
63     int16_t iqWidth;    /*!< Bit size */
64
65     int32_t len; /*!< Length of input data. */
66 };
67
68 /*!
69     \struct xranlib_decompress_response
70     \brief Response structure containing pointer to data and its length.
71 */
72 struct xranlib_decompress_response {
73     int16_t *data_out; /*!< Pointer to data after decompression. */
74
75     int32_t len; /*!< Length of output data. */
76 };
77
78 /*!
79     \brief Report the version number for the xranlib_companding library.
80     \param [in] version Pointer to a char buffer where the version string should be copied.
81     \param [in] buffer_size The length of the string buffer, must be at least
82                xranlib_SDK_VERSION_STRING_MAX_LEN characters.
83     \return 0 if the version string was populated, otherwise -1.
84 */
85 int16_t
86 xranlib_companding_version(char *version, int buffer_size);
87
88 //! @{
89 /*!
90     \brief Compress functions - it converts a 16-bit linear PCM value to 8-bt A-law.
91     \param [in]  request Structure containing the input data and data length.
92     \param [out] response Structure containing the output data and data length.
93     \return 0 for success, -1 for error
94 */
95 int
96 xranlib_compress(const struct xranlib_compress_request *request,
97     struct xranlib_compress_response *response);
98
99 int  xranlib_compress_sse(const struct xranlib_compress_request *request,
100     struct xranlib_compress_response *response);
101 int  xranlib_compress_avx2(const struct xranlib_compress_request *request,
102     struct xranlib_compress_response *response);
103 int xranlib_compress_avx512(const struct xranlib_compress_request *request,
104     struct xranlib_compress_response *response);
105 int xranlib_compress_avx512_bfw(const struct xranlib_compress_request *request,
106     struct xranlib_compress_response *response);
107 //! @}
108
109 //! @{
110 /*!
111     \brief Decompress function - it converts an A-law value to 16-bit linear PCM.
112     \param [in] request Structure containing the input data and data length.
113     \param [out] response Structure containing the output data and data length.
114     \return 0 for success, -1 for error.
115 **/
116 int
117 xranlib_decompress(const struct xranlib_decompress_request *request,
118     struct xranlib_decompress_response *response);
119
120 int xranlib_decompress_sse(const struct xranlib_decompress_request *request,
121     struct xranlib_decompress_response *response);
122 int xranlib_decompress_avx2(const struct xranlib_decompress_request *request,
123     struct xranlib_decompress_response *response);
124 int xranlib_decompress_avx512(const struct xranlib_decompress_request *request,
125     struct xranlib_decompress_response *response);
126 //! @}
127
128 #ifdef __cplusplus
129 }
130 #endif
131
132 #endif /* _XRAN_COMPRESSION_H_ */